A
A
Actor2012-12-03 05:58:51
linux
Actor, 2012-12-03 05:58:51

Freeing and Shrinking Linux Cache Memory?

Hello, I rent a cloud and for the most part the machine is idle, but the memory in the statistics (and score) is constant.
Before the commands I tried:

# free
             total       used       free     shared    buffers     cached
Mem:        163840      30048     133792          0        900       4916
-/+ buffers/cache:      24232     139608
Swap:       249852       1728     248124

I do
# sync
# echo 1 > /proc/sys/vm/drop_caches
# sync
# echo 2 > /proc/sys/vm/drop_caches
# sync
# echo 3 > /proc/sys/vm/drop_caches
I get
# free
             total       used       free     shared    buffers     cached
Mem:        163840      29224     134616          0         52       4908
-/+ buffers/cache:      24264     139576
Swap:       249852       1728     248124

As you can see, the cache remained 140MB as it was, and only 24 MB are occupied by real applications.
How to reduce the cache and not keep it, so that the cloud hoster does not count memory when idle.
Debian Squiz 32

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
alan85, 2012-12-03
@alan85


vm.vfs_cache_pressure = ....
Try the /etc/sysctl.conf option . Might help.

A
Alexey Akulovich, 2012-12-03
@AterCattus

If you upgraded packages and did not reboot after that, then the memory may be occupied by old versions of the lib.
Something like this:

00007fcd764af000 2044 — — — ----- libdigestmd5.so.2.0.23
00007fcd766ae000 4 — — — r---- libdigestmd5.so.2.0.23
00007fcd766af000 4 — — — rw--- libdigestmd5.so.2.03
00007fcd766b0000 36 — — — rx-- libcrypt-2.11.1.so (deleted)
00007fcd766b9000 2048 — — — ----- libcrypt-2.11.1.so (deleted)
00007fcd768b9000 4 — — — r---- libcrypt- 2.11.1.so (deleted)
00007fcd768ba000 4 - - - rw--- libcrypt-2.11.1.so (deleted)

It will help to restart the corresponding programs, or a complete restart of the server.

L
Lev Lybin, 2012-12-03
@lybin

This is virtual memory reserved by running applications.

I
ilnarb, 2012-12-05
@ilnarb

Here are the sysctl parameters that allow you to control caching:
- vm.pagecache - for example, lower it to 10 or even lower.
- vm.vfs_cache_pressure - set to 100 or more.
- vm.drop_caches - you already know about it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question