views:

68

answers:

3

Hello!

Please let me know what is the best way to determine composition of young generation memory promoted to old generation, after each young GC event?

Ideally I would like to know class names which are responsible say, for 80% of heap in each "young gen -> old gen" promotion chunk;

Example: I have 600M young gen, each tenure promotes 6M; I want to know which objects compose this 6M.

Thank you.

A: 

are any of the JDK 6 options below can help it? http://www.md.pp.ru/~eu/jdk6options.html

Java Geek
A: 

current answer I got form sun/oracle is this: buy JFB+ (java for business plus) at $100K/year and we will build a custom jvm for you;

but looking on JDK 6/7 sources it feels more like a couple of weekends hack;

anyone wants to join?

Java Geek
specifically, there is c++ code in jvm for -XX:+PrintGCDetails and XX:-PrintClassHistogram which need to be re-used to produce printout at each ParNew gc invocation
Java Geek
+2  A: 

Hey!

There is no easy way to do this, however, I have recently been analyzing memory performance of large java apps, and can share some experience.

Here is how I found what objects are being promoted to old gen:

First you need to identify what objects are in "old/tenured" space. This is basically you standard java heap analysis. For this I recommend jmap. It is part of the sun jvm. run: jmap -dump:file=heap.hprof PID to get a heap dump. This will pause the jvm during the dump (~for 30 secs on a 2GB heap)

Now load the .prof file in Memory analyser (the best tool for this, hands down) I would spend a day playing with Memory analyzer to understand it, watch the screencam (needs a login, but worth it).

Now you will know what objects are in your heap.

Here is the trick: In the overview screen of Memory analyser, there is a link to: "Unreachable objects histogram". Now these objects are all to be collected during the next GC. But some are probably in eden, some in survivor and some in old.

Now, get some profiler with memory profiling capability, I prefer yourKit. Run your app with yourkit and record object allocation.

Run it and record object creation. Once you have a list of objects created use all three lists to get a picture of what is going on. Do what humans do best, see patterns.

  • What objects are created and are reachable. (Memory analyser)
  • Objects unreachable in heap (Memory analyser)
  • Objects created during a run (Profiler)

Another way to approach is YourKit generations view. You can take snapshots of your heap and compare what objects are still alive between snapshots. If you use this with visualgc you can determine how long an object must be alive to be promoted to old gen, and take snapshots at these intervals to see what objects are still alive.

Well, good luck. /JT

JT