Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitoring memory consumption by different java objects

If we have 300 classes in an application, is it possible to monitor how many instances of each class we have at a given time? Is it possible to know how much memory each instance is consuming?

Thanks

like image 829
craftsman Avatar asked Sep 17 '09 10:09

craftsman


People also ask

How do I check my Java memory usage?

Using VisualVM (jvisualvm) jvisualvm is a tool to analyse the runtime behavior of your Java application. It allows you to trace a running Java program and see its the memory and CPU consumption. You can also use it to create a memory heap dump to analyze the objects in the heap.

How much memory does a Java object use?

Object references consume 4 bytes. boolean and byte values consume 1 byte. short and char values consume 2 bytes. int and float values consume 4 bytes.

Which is used for memory usage analysis in Java?

jvisualvm is one of the memory analysis tools for Java used to analyze the runtime behavior of a Java application. It traces a running Java program, checking its memory and CPU consumption. Also, it is used to create a memory heap dump to analyze the objects in the heap.

How do I monitor JVM heap?

The easy way to monitor Heap usage is by using a commercial APM (Application Performance management tool) such as CA Wily APM, AppDynamics, New Relic, Riverbed, etc. APM tools not only monitor the heap usage, but you can also configure the tool to Alert you when Heap usage is not normal.


1 Answers

JDK 1.6 includes a tool called jvisualvm, which allows you to view lots of information about your running Java program, including memory usage, threads, etc. You could also use a profiler to see this kind of information. The profiler in NetBeans looks a lot like JVisualVM.

like image 54
Jesper Avatar answered Oct 05 '22 05:10

Jesper