# Asterisk does not free the memory allocated for the CPU cache

**URL:** <https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009>\
**Category:** Asterisk Support\
**Created:** [September 20, 2021, 5:26am UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009 "2021-09-20T05:26:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ogogon](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ogogon/32/1597_2.png) [@ogogon](https://community.asterisk.org/u/ogogon)\
**Post date:** [September 20, 2021, 5:26am UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009/1 "2021-09-20T05:26:44Z")

</div>

Colleagues, tell me, from which side should I approach the problem?

Apparently, Asterisk occupies, but does not free up memory for the CPU cache during operation.

I am using the htop utility and I see yellow characters growing in the Mem section, indicating the fraction of RAM used by the CPU cache. At the same time, the memory occupied by the kernel, applications, and buffers is freed quite normally.

Here is what is said in detail about cache - “kernel memory residing in RAM and used to store the contents of files read from disk”.  
In about one or three days of operation, this cache takes up all the memory and problems begin with sound streams - in fact, they start working 10-20 seconds after connecting. After a reboot, the amount of memory occupied by this cache decreases to a very small one, and in the absence of a telephone load, it hardly grows or grows, but very slowly.

Where to find the cause of the problem?  
Appreciated in advance for ideas.

Ogogon.

---

<div class="post-metadata">

**Author:** ![EkFudrek](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@EkFudrek](https://community.asterisk.org/u/EkFudrek)\
**Post date:** [September 20, 2021, 7:50am UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009/2 "2021-09-20T07:50:25Z")

</div>

Why do you think is this a problem?

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [September 20, 2021, 10:03am UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009/3 "2021-09-20T10:03:22Z")

</div>

As well, that’s not Asterisk’s to free. That’s normal functionality of the Linux kernel to use unused memory for disk cache. Looking elsewhere to identify your issue is most likely required.

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [September 20, 2021, 10:14am UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009/4 "2021-09-20T10:14:18Z")

</div>

Both Linux and Windows maximise memory usage in this way, as a matter of policy; as Joshua says, it is completely normal. The only time cache would be a warning sign is is it was becoming very small. I don’t have htop on the machine I’m using, but free, actually displays both a free and available memory figure, where the latter excludes buffers and cache.

Also, this is not the CPU cache, it is a backing store (e.g. disk) cache.

---

<div class="post-metadata">

**Author:** ![ogogon](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ogogon/32/1597_2.png) [@ogogon](https://community.asterisk.org/u/ogogon)\
**Post date:** [September 20, 2021, 2:31pm UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009/5 "2021-09-20T14:31:53Z")

</div>

> [@EkFudrek](#):
>
> Why do you think is this a problem?

I suppose something is not working quite right. If I knew a more precise answer, I would not ask the question.

---

<div class="post-metadata">

**Author:** ![ogogon](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ogogon/32/1597_2.png) [@ogogon](https://community.asterisk.org/u/ogogon)\
**Post date:** [September 20, 2021, 2:34pm UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009/6 "2021-09-20T14:34:17Z")

</div>

> [@jcolp](#):
>
> As well, that’s not Asterisk’s to free. That’s normal functionality of the Linux kernel to use unused memory for disk cache. Looking elsewhere to identify your issue is most likely required.

Do you think this is an operating system problem? Thanks.

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [September 20, 2021, 2:36pm UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009/7 "2021-09-20T14:36:24Z")

</div>

No? I do not know. You’d have to do analysis. Look at packet captures, identify the specific scenario, isolate further.

---

<div class="post-metadata">

**Author:** ![ogogon](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ogogon/32/1597_2.png) [@ogogon](https://community.asterisk.org/u/ogogon)\
**Post date:** [September 20, 2021, 2:41pm UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009/8 "2021-09-20T14:41:01Z")

</div>

> [@david551](#):
>
> Also, this is not the CPU cache, it is a backing store (e.g. disk) cache.

On the Wikipedia page about htop, exactly the phrase I quoted is written. True, the most informative was the Russian-language page. Especially for fans of Chekhov, Tolstoy and Dostoevsky - [htop — Википедия](https://ru.wikipedia.org/wiki/Htop)

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [September 20, 2021, 2:43pm UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009/9 "2021-09-20T14:43:33Z")

</div>

I don’t think there enough information to know why your media is slow to start.

I suppose it could be a virtualisation problem, if the virtual machines doesn’t have enough memory dedicated to it to cover its simulated physical memory and there is something like VMWare’s memory balloons which eat up lots of memory temporarily to force cached pages to be thrown away. These require that you include the VMWare support in your virtual machine. That sort of situation could lead to thrashing on the host, even though the VM appeared to have plenty of memory.

As I said, both Linux and Windows try to make use of as much physical memory as they can, with only a small safety margin, so you should only allocate virtualise physical memory that can actually be backed by real physical memory.

---

<div class="post-metadata">

**Author:** ![EkFudrek](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@EkFudrek](https://community.asterisk.org/u/EkFudrek)\
**Post date:** [September 20, 2021, 4:41pm UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009/10 "2021-09-20T16:41:11Z")

</div>

> [@david551](#):
>
> I suppose it could be a virtualisation problem,

I’ve seen some small ARM devices that also show this kind of behavior, though theoretically there should have been more than enough CPU power and RAM. It’s difficult to help, if there is nothing that one can refer to.

---

<div class="post-metadata">

**Author:** ![EkFudrek](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@EkFudrek](https://community.asterisk.org/u/EkFudrek)\
**Post date:** [September 20, 2021, 4:44pm UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009/11 "2021-09-20T16:44:59Z")

</div>

> [@ogogon](#):
>
> If I knew a more precise answer, I would not ask the question.

Your question cannot be answered based on the lack of details. You need to make use of your freedom to explore your entire environment to find out more about the possible cause. Since your problem does not show up in every second comment here, it is fairly safe to assume that there is no general Asterisk bug here.

Since you are obviously a Dostoevsky fan let me answer with a parable from The Brothers Karamazov. Here’s nobody strong enough to take on the burden of freedom for everybody else and nobody -not even Wikipedia- can give simple answers to all of your questions so you can happily live in ignorance.

Memory that is not immediately needed will get cached eventually so that the overall system performance increases. If that’s not the case, you need to look the overall setup.

---

<div class="post-metadata">

**Author:** ![ogogon](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ogogon/32/1597_2.png) [@ogogon](https://community.asterisk.org/u/ogogon)\
**Post date:** [September 21, 2021, 12:11am UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009/12 "2021-09-21T00:11:29Z")

</div>

> [@EkFudrek](#):
>
> Since you are obviously a Dostoevsky fan

In no case!

How can I be a fan of a man who in his youth was a fighter for freedom and democracy, was convicted for reading a letter from a famous critic to a famous writer in a circle of intellectuals, broke morally during imprisonment and returned to freedom already completely agreeing with his jailers?  
Then he wrote works in which he described people with various severe moral and mental defects, enjoying a detailed understanding of their circumstances. At the same time, he himself was a gloomy misanthrope, suffered from several neuro-psychiatric diseases and gambling addiction.  
In other words, Dostoevsky is also a character in Dostoevsky’s novel.

He even died of a severe fit of fear when he learned that the gendarmes had arrested the hiding revolutionary Barannikov in a neighboring apartment. Dostoevsky considered that he could be condemned again, in view of his past. A severe panic attack awakened a number of somatic diseases and Dostoevsky died of pulmonary hemorrhage.

Do you want to be a fan of such a person?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [October 21, 2021, 12:11am UTC](https://community.asterisk.org/t/asterisk-does-not-free-the-memory-allocated-for-the-cpu-cache/90009/13 "2021-10-21T00:11:36Z")

</div>

Closed on October 21, 2021, 12:11am UTC

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