I have a potentially problematic application that may have memory leak issues. However, in the process of investigating this, I've come across what seems to be conflicting information.
When I use free
to get a summary of memory usage on the server, there appears to be plenty of available RAM:
[alice@myserver]$ free -h
total used free shared buff/cache available
Mem: 9.8G 2.4G 131M 3.6G 7.2G 3.5G
Swap: 0B 0B 0B
However, if I use top to check the process of interest, it shows that single process using almost all of the available RAM:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
16907 alice 20 0 158.6g 9.1g 7.6g S 63.2 92.8 6476:48 my_task
Even if I count all of used(2.4G) and shared(3.6G), that is still only 6.0G, much less than the 9.1G top says this single process is using.
Which do I believe, top
or free
?
Some additional details, in case they are relevant:
- OS is CentOS 7.7
- my_task is a Java application running JDK 15 with ZGC
- my_task uses JNI and does allocate a lot of memory off-heap (1-2GB is expected, not 4 or 5GB)
- max heap size is 3GB, but VisualVM is showing the total heap to be ~2GB with only ~1GB allocated