free -m
shows me the following in my system:
total used free shared buffers cached
Mem: 3954 3842 111 0 248 2585
-/+ buffers/cache: 1008 2945
Swap: 3811 4 3807
So memory looks pretty used up, but top
sorted by memory shows the following top-processes:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8891 minecraf 20 0 2374m 277m 9.9m S 1 7.0 0:12.21 java
8704 root 39 19 2802m 272m 11m S 0 6.9 0:28.73 java
The virtual memory used by java seems to be huge, but i learned on the internet that that's not a problem. So i guess my question is: Why does free
show the virtual memory, if it's not that meaningful?
Best Answer
The "Mem" line of
free
doesn't show virtual memory usage, it shows physical memory usage.The "RES" (for resident) and "%MEM" columns from
top
shows you the same: the physical memory being used by each process.free
does show you the available and used swap space, andtop
has its "VIRT" column, both of which can be important. Roughly, swap space plus physical memory gives you your total possible virtual memory space. Get up to that limit and you'll start getting processes killed or unable to allocate memory and things will be bad.