Free DRAM notes

Sometimes I found that my program’s performance got really bad after a long series of benchmarks. The reason is the amoutn of “free memory” is low. Why is this happening? Here are some notes exploring this problem, and ways you can clean up your memory.

Of all the posts I found, this is the best explaining why we have free memory.
A great discussion post from Stackoverflow
The problem is that you have page caches, and slab objects around in memory (serving as disk cache). This can be potentially a problem for high performance applications.
Here is a way to check if you have the problem and deal with it.
(One approach to free up memory first suggested by Vladimir Kiriansky, my office mate).
first check after a job that you’re indeed NUMA imbalanced:
numactl -H | grep free

and add this function to a file.


drop_caches() {
echo Dropping PageCache and SLAB objects,
# first give priority to handling dirty data, so we can free it all
sudo sync;
echo 3 | sudo tee /proc/sys/vm/drop_caches
or you can
and you can call the function from other scripts (or your shell)
Documentation on drop_cache
Slab cache
Page cache
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s