Discrepancy between Memory Live chart and htop
Answered
Running Intellij 2021.1.2 Ultimate on Ubuntu16.04.6 LTS
Using the memory profiling tool to run a Java process (jar file) shows it using around 250MB max and 80MB after forced garbage collection for heap memory, and stable 160MB for non-heap memory. That adds to around 250MB to 400MB memory usage.
The command for the run is java -jar {FILENAME}.jar
Using htop command in command line, and checking the process with its PID obtained by the jps command, it shows the memory usage of that jar file at 840MB.
What is causing this discrepancy? Which one should I trust to be the actual RAM usage?
Please sign in to leave a comment.
Hello,
The memory snapshot captured via IDEA shows RAM used only by the JVM, while htop shows total RAM usage. (JVM + native memory, etc.).
To analyze a Java process in most cases it is enough to analyze only the JVM heap.
Some useful information can be found at https://intellij-support.jetbrains.com/hc/en-us/articles/360018776919 .