How to record and display object lifetime for Java applications?

We want to adjust the size of the memory pool for our Java application. To do this, we first need to understand how the heap is used. Essentially, we need to know the number, size, and lifetime for each object in the JVM heap. After we have collected this data, we will be able to find more suitable sizes for our young and experienced generating pools.

We base our efforts on tuning the information contained in the "Tuning Garbage Collection with 5.0 JVM" from Sun / Oracle. In section 3 ( http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html#1.1.%20Generations%7Coutline ) they discuss the size of semantics and show an example on the life graph of an object. Quite a lot of what we are trying to achieve for our application.

So far, we have managed to record the number of instances for this class and their corresponding sizes in memory. However, I cannot find a way to extract the average lifespan of an instance. Right now we are looking through jProfiler, but so far without success.

Has anyone been successful in plotting the average lifetime of an object for Java applications?

+3
source share
1 answer

To configure GC, you usually do not need the lifetime of each object, but this is a good overview of pools in real time. The first thing I usually do is look at the various pools using visualgc, which is part of jvmstat (http://java.sun.com/performance/jvmstat/). Then I go on to check for memory leaks. This is by far the best way I've come across.

and. In jconsole, you can see if you are constantly overflowing into the old gene prematurely (this means that the eden was too large to fit in the survivor gc even after it). If so, check the rate of youth and survival and try to adjust them so that it does not overflow.

. , "" visualgc , , .

, . jconsole MAT (http://www.eclipse.org/mat/):

  • jconsole.exe dumpHeap() HotSpotDiagnostic MBean (, .hprof)
  • MAP , - , , .

.

+2

All Articles