Using Linux 3.2.0-24-virtual #37-Ubuntu SMP Wed Apr 25 12:51:49 UTC 2012 i686 i686 i386 GNU/Linux
in a Xen VPS.
Before I run a Grails java app, running free -m
indicates:
total used free shared buffers cached
Mem: 4031 155 3875 0 30 87
-/+ buffers/cache: 37 3994
Swap: 8191 0 8191
After running the Grails app, performing some memory intensive processing, and quitting via Ctrl-C
, it indicates:
total used free shared buffers cached
Mem: 4031 1031 2999 0 33 957
-/+ buffers/cache: 40 3991
Swap: 8191 0 8191
which doesn't seem to change until a reboot. top
and ps aux
don't indicate any heavy mem usage. The Grails app is the only app I run on this machine.
Perhaps I'm misinterpreting this, but I'm concerned that memory doesn't seem to be freeing post-quit. Normally I'd suspect a memory leak, but how is that possible once the java app has been terminated?
You are actually misinterpreting the output of the command.
The Mem
line shows how much memory is currently allocated by the kernel; however, the kernel releases memory lazily. If no other process is requesting memory, it might keep allocated pages (maybe stuff read from disk).
The row where you see the "clean" used/free memory is the -/+ buffers/cache
row, where you can see that your memory usage is approximately the same.
You can find some more detailed explanation on the web, e.g. here.