Memory Consideration for Asterisk

Hi All,

I need to know something , Does asterisk considee buff/cache memory as a free Memory ? and If there is no available Memory in Free , What will asterisk do then ?

Thank You

The Buffer/Cache versus Free distinction is an OS one, not an application programme one. Linux (and for that matter Windows) will aim to keep a small amount of free memory, but no more, so if free memory is not low, you probably have too much physical memory for your actual needs.

If there is insufficient available memory, the OS will start using swap spac, with a risk of thrashing.

You really should not operate Asterisk in an environment where memory is low, as it is a real time application and thrashing will cause excessive jitter. whilst it is better to dedicate hardware, it may be OK to let concurrent applications swap out, and similarly for unused parts of Asterisk.

I’ve never run Asterisk into memory distress, but I think it will refuse calls and possibly drop media.

1 Like

That’s why I asked if asterisk can use /consider Cache/Buff Memory as a free memory ?
As far as I know that OS reserves a piece of memory in cache to increase the speed of disk access .

Asterisk doesn’t decide. Asterisk allocates memory, and the system provides it. It’s up to the system to take from the cache, for example.

1 Like

To make the most efficient use of real memory, Linux automatically uses all free RAM for buffer cache, but also automatically makes the cache smaller when programs need more memory.

Like everyone has said; Asterisk doesn’t manage memory, the kernel does. Here’s a memory output from my Asterisk VM:

MiB Mem : 1951.0 total, 111.8 free, 399.0 used, 1440.2 buff/cache

By default Linux “takes” all the ram for buffer. As programs ask for memory, the kernel automatically reduces the amount of buffer/cache to compensate. Granted my Asterisk doesn’t handle very many calls; the entire VM is using less than 512MB right now. But if it asked for say, 200 more MB of ram; the kernel would reduce the cache by 200MB. If I look at my XenOrchestra; it says I’m using the full 2GB. Technically it is; but the VM is far from being out of ram from an os perspective.

1 Like

Not really. The OS reserves a certain amount of free memory, to satisfy short term demands. Otherwise, anything read from or written to the disk is left in memory, in case it is needed again, and is accounted for in the cache figure. The significance of this is that, at a push, data that has been read or written can be thrown away, in order to satisfy a memory request, and data that is awaiting being written can actually be written.

In practice, I believe you need a significant amount of cache space because most program code is pure, so read/write pages don’t have to be allocated to it, and it can be swapped off the original executable file, without the need to use swap space, but with a significant time penalty. Whilst the OS can run the cache allocation down to a very low value, without refusing memory requests, that can be at the cost of no longer having real time performance.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.