This command is very useful to free buffers when you face lack of memory issue. Free memory can be seen from the output of common linux command “free”:
Real free memory = free + buffers + cached
To clean up buffers and cached memory, use defrag_mem:
[root]# free
total used free shared buffers cached
Mem: 1033972 987192 46780 0 159204 309176
-/+ buffers/cache: 518812 515160
Swap: 4192956 68 4192888
Here we can see that free memory calculation formula is:Real free memory = free + buffers + cached
To clean up buffers and cached memory, use defrag_mem:
[root]# gcc -o defrag_mem
[root]# ./defrag_mem 500M
[root]# free
total used free shared buffers cached
Mem: 1033972 482504 551468 0 612 7760
-/+ buffers/cache: 474132 559840
Swap: 4192956 112964 4079992