How to reduce cached memory?

Suren Karapetyan surenkarapetyan at gmail.com
Sat Feb 7 13:26:52 UTC 2009


Joshua C. wrote:
> 2009/2/7 Adrian Joian <adrian.joian at fedoraproject.ro>:
>   
>> Hello,
>>
>> Well, if you really want to decrease cache levels you could at schedule
>> at random times the following command:
>> echo 1 > /proc/sys/vm/drop_caches
>>
>> Adrian JOIAN
>> fedoraproject.ro
>>
>> Chris Tyler wrote:
>>     
>>> On Fri, 2009-02-06 at 23:57 +0100, Joshua C. wrote:
>>>
>>>       
>>>> I have kde 4.2 and f9. After 2+ hours on my computer it has about
>>>> 1,4GB cached memory. I don't see him releasing this memory after time.
>>>> I know it comes from the apps being open but it seems the kernel
>>>> "never" releases the memory after the app terminates. How to make the
>>>> kernel free this memory? I've seen similar cases with kde 3.5.10 and
>>>> f8 and f7. I know kde eats memory but this is too much. Who caches so
>>>> much of it? Why?
>>>>
>>>> The mashine has 2,6 GB RAM (still x86) and 512mb swap which is rarely
>>>> used (~ 50mb at most) and combined cached + app memory totals about 2
>>>> gb.
>>>>
>>>>         
>>> Hi Joshua,
>>>
>>> Memory is being used for cache basically because it's not being used for
>>> anything else. The kernel will gladly use that memory for other purposes
>>> when it's needed -- but until then, there's no harm in keeping disk data
>>> around in otherwise-unused memory just in case it's needed later.
>>>
>>> This is why the "free" command shows a "-/+ buffers/cache" line, which
>>> shows you what the memory picture is without the cache (i.e., the memory
>>> that is truly available when needed):
>>>
>>>   $ free
>>>                total     used    free  shared buffers cached
>>>   Mem:       4061388  3796632  264756       0  259244 570224
>>>   -/+ buffers/cache:  2967164 1094224
>>>   Swap:      4194296  2092276 2102020
>>>
>>>
>>> -Chris
>>>
>>>
>>>       
>> --
>> fedora-devel-list mailing list
>> fedora-devel-list at redhat.com
>> https://www.redhat.com/mailman/listinfo/fedora-devel-list
>>
>>     
>
> Than you everyone for the replies. Swapping do occurs (although
> rarely) but this is not my concern. What I don't like is the fact,
> that the kernel fills the memory with "what he thinks I would use/like
> or have already used". I didn't know it will use the cached memory in
> case it's needed.
>
> But then is the question: When swapping occurs where have the other
> 2,6 gb ram gone? I don't believe I've opened so many apps that can
> consume so much memory.
>
>   
That's another aspect of linux VM subsystem (read: 
http://lwn.net/Articles/83588/).
To be short, kernel decides to swap out unused program pages from 
physical memory to the disk.
This clears physical memory for cache use.

Example: You open OOo Writer and leave it alone for half an hour.
Kernel decides You aren't going to use it soon, and swaps (all) it's 
pages out.
That gives the kernel additional ~100 MBs to cache the movie You're 
editing in Kino.




More information about the fedora-devel-list mailing list