I'm using ubuntu 14.04. IS there any way to find how much heap is used by the java class or process?
When I run top command, %CPU and %MEM denotes what?
I'm using ubuntu 14.04. IS there any way to find how much heap is used by the java class or process?
When I run top command, %CPU and %MEM denotes what?
The output of top
gives you the CPU and memory usage of a single Java virtual machine. Concurrency in Java programs is usually achieved using threads, i.e. you have many threads inside a single Java virtual machine. To get more information about the memory usage of a particular thread or other component of a Java program, you have to look inside the virtual machine, for example by capturing a heap dump and analyzing it using MAT. MAT and other tools are also explained in How do I analyze a .hprof file?. Another possibility should be attaching VisualVM to the Java virtual machine but I've never used it myself.
You can use jvisualvm that is included in the JDK.
$YOUR_JAVA_HOME/bin/jvisualvm.
In the profiler, you can choose either CPU or Memory profiling that should show you what you want.
You can find some documentation here : https://visualvm.java.net/profiler.html