1

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?

mohankrish
  • 25
  • 2

2 Answers2

0

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.

Community
  • 1
  • 1
aha
  • 3,702
  • 3
  • 38
  • 47
0

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

nono
  • 1,462
  • 1
  • 13
  • 21