Memory gets full after every couple of days

Hi,

I cant figure out why memory gets full after every couple of days. I have to free it using “echo 1 > /proc/sys/vm/drop_caches” command. Might be memory leak but I cant find the source.
I am using Ubuntu 14.04.4

voip:/etc/asterisk# free -m
total used free shared buffers cached
Mem: 7979 7717 262 10 227 6557
-/+ buffers/cache: 932 7046
Swap: 8183 0 8183

Using “top” command, I cant find any process using more then 3-4% of memory

The Linux disk cache is very unobtrusive. It uses spare memory to greatly increase disk access speeds, and without taking any memory away from applications.

It is a bad practice to drop the cache Unless you’re trying to address a performance issue, there’s no need to prevent any cache use. When you drop the cache (or caches), you will see the CPU load go up (sometimes way up) because the cache is gone. Available RAM goes up, but it does not matter because performance is slower because the cache is empty.

Then over time, if you leave the caches off, the performance will suffer because you are not taking advantage of the cache.

Linux tries to use all available RAM, so the caches will fill over time if you don’t instruct Linux to drop the caches, and this is a good thing. You will see available RAM go down, but don’t worry, it is available for applications when needed because applications take higher priority than cache

If Asterisk is not involved on this issue ,next questions must be addressed outside this forum,

Actually when memory gets full, calls start dropping. whenever I dial, most of the time call doesn’t go through and gives the following error.

“== Everyone is busy/congested at this time (1:1/0/0)”

Unless I drop the cache, I’m unable to make a call.

And yes I did read about dropping cache being bad practice but unable to find a way around

This is an OS problem, not an Asterisk one. You have about 7GB of effectively free memory and the OS should be performing on that basis.

Note, if Asterisk is suffering from memory starvation, there should be warnings/errors when the relevant system call fails, not just lhe secondary/tertiary symptom you are reporting here.

The fact that your swap usage is zero is confirmation that you do not have memory starvation.

One thing. Is this a virtual machine. If so reduce the allocated memory to 1 or 1.5GB and make sure there is that much physical memory on the host to fully back it up.

Well I’m new to Asterisk and Linux, so wasn’t sure if Asterisk was eating the memory. And secondly 7GB was not free, that was used memory, only 262MB was free (columns weren’t aligned).
Thirdly its a physical machine. Nyway Thanx for the support, I’ll post the issue on Ubuntu forms.

7046 MB are effectively free. The purpose of the +/- line is to show the true amount of free and used memory that cannot be thrown away at a moment’s notice.

Incidentally, Windows NT family systems (all modern Windows) use the same trick and also runs with nearly all memory allocated on systems that are not totally over-provisioned.

Yes 7046MB is free for buffers/cache but only 262 MB RAM was free and somehow calls don’t go-through if RAM is fully used.

I might be misinterpreting the output of “free -m”, will google it to get a better understanding of it.

Whatever the case dropping cache frees the RAM, and yes its not a solution, but solves my problem for couple of days.

Linux and Windows deliberately run with very little completely unused RAM, so you should always expect them to use nearly all of however much RAM you give them.

Can you please confirm that you are running this directly on real hardware.

Run:
asterisk -rx “core show taskprocessors”

What is the asterisk version?

Also, when using top, press CTRL+M to sort by memory usage.

Yes its real hardware (dell poweredge 1950) not VM

Okay, I’ll do that once memory gets high.
currently the output is

> core show taskprocessors

>         +----- Processor -----+--- Processed ---+- In Queue -+- Max Depth -+
>                app_queue                7494            0            1
>    core_event_dispatcher               14215            0            2
>            app_voicemail                   0            0            0
>                 pbx-core                7502            0            1
>            ast_msg_queue                   0            0            0
>                CCSS core                   0            0            0
>            iax2_transmit                   0            0            0
>         +---------------------+-----------------+------------+-------------+
>         7 taskprocessors

I did pressed CTRL+M when using top, max memory used was 3% by voipmonitor

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND

 1499 root      20   0  466144 243680  69612 S   3.0  3.0 130:06.02 voipmonitor
 2022 root      20   0 3959020  53068  23428 S   0.7  0.6  23:15.40 asterisk

I’m using Asterisk 11.7.0

Hello,

I encounter the same problem. it does not seem solved. I created 4 VM with Hyper V (4 centos 7 / kernel 5.0.10 / Asterisk 13.26.0 patched)

The servers has no trafic for the moment (not in production) but the memory goes from 500MB to 5GB after a couple of days only. Without any activity on asterisk !

HI!

This problem happens to me too. I use asterisk 1.8 on Ubuntu 14.04 servers. Does anyone know any solution?

The solutions to Asterisk 1.8 are Asterisks 13 and 17!

By 1.8, do you mean 1.8.32.2? If not you need to upgrade to at least that even to fix all bugs that were fixed in 1.8.

Otherwise, you need to work out what in your use of Asterisk causes the memory leak, and stop doing that. The amount leaked per call may be a clue.

The only partially valid reason for having 1.8 is that this is an old system, in which case it seems likely that there were no memory leaks in the almost six years since it went into security fix only status, so what recently changed and started producing leaks?

Further information on the information needed can be found in https://wiki.asterisk.org/wiki/display/AST/Memory+Leak+Debugging However please note that bug reports about Asterisk 1.8 will always be rejected.

haha! I already know that later versions fix problems. But this version is part of a project and it is not so easy to update to the latest version.

The version is 1.8.28 runs in conjunction with MySQL.

The error occurs after a time without restarting and after many calls. It seems that it was occupying memory but it does not free it. You understand me ?

Yes, it is an old system, but this occurred in a client with a lot of call traffic. Perhaps the system was overwhelmed.

Thanks for your time!

People are not going to remember what memory leak bugs exist in an 8 year old (almost) version of Asterisk.

If you can’t upgrade, you are going to have to work out what is unusual about the system, then start removing that until the leak stop.

The only other option would be to look through the change logs since November 2012, to see if you recognize one that fixes a memory leak that might apply in your case.