2

The server has about 24GB memory. By running free -g I find the memory is used up

             total       used       free     shared    buffers     cached
Mem:            23         23          0          0          0         18
-/+ buffers/cache:          4         19
Swap:           56          2         53

Then I did some research into what has used up all these memory by top then M. But it seems the memory is quite free in the %MEM column.

What can I do to free some memory? This is a server for calculation so it is better not to restart the computer.

  • 3
    What issues are you experiencing that require you to free up the cached/buffer memory? – Matt May 9 '14 at 6:07
  • @mtm After finding out the meaning of free column of buffer/cache row, I guess it is just OK. The server does not cache that lot before. – onemach May 10 '14 at 0:57
3

You're misinterpreting the output of free. What you posted is showing that you have 19 GB of RAM free. The 23 GB you're seeing is used by the system as cache but is still readily available for applications. That is also why top shows the memory as free..

See Linuxatemyram.com for a more detailed explanation

0

You can refer to this question for determining exact free memory.

  • By default the linux has a very efficient memory management process that should be freeing any cached memory on the machine that it is being run on.

  • However when it comes to cached memory, linux may at times decide that the cached memory is being used and is needed which can lead to memory related issues and ultimately use up the free memory. To counter it, you can force linux to free up any stored cached memory.

To free memory immediately, you can simply do this,

free && sync && echo 3 > /proc/sys/vm/drop_caches && free

EDITED: You can also run this command as a cronjob.

As @mjturner pointed out, it not very recommended as it can cause performace bottlenecks.

  • What if I do not have root access on my system? – Bernhard May 9 '14 at 6:14
  • 1
    Linux creates the page and fs caches for performance reasons. I'm not sure dropping them hourly will be of much benefit. Maybe on a memory constrained machine where you don't rely on the fs much. – Matt May 9 '14 at 6:16
  • @Bernhard you will need root, or at least sudo root access. – Matt May 9 '14 at 6:16
  • Memory is managed at kernel level, you need atleast sudo root access. You need to give some input on what issues are affecting for further clarification as @mtm suggested. – delta24 May 9 '14 at 6:23
  • 1
    @delta24 I don't think freeing the page cache every hour is wise advice. From the Linux kernel documentation: Use of this file can cause performance problems. Since it discards cached objects, it may cost a significant amount of I/O and CPU to recreate the dropped objects, especially if they were under heavy use. Because of this, use outside of a testing or debugging environment is not recommended. – mjturner May 9 '14 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.