Frage

In a java heap dump how do I know exactly where in the code/which thread caused the dump?

War es hilfreich?

Lösung

For reading the memory dumps:

I would recommend you to try "eclipse memory analyzer" From here

Another option (free) would be opening this with JVisualVM (available at $JAVA_HOME/bin) jhat is cool too but was already recommended :)

Now, you're asking about the thread that caused memory heap-dump and not about how to proceed with memory dump... It depends on how did you obtain the memory dump. There are different ways to obtain the dump.

  1. On your process you can instruct the JVM to produce memory dump once OutOfMemory error is encountered, in this case I believe it will be the JVM itself.

  2. You can trigger the heap dump creation from the MBean given you have a JMX Server running along with your JVM Example

  3. You can even use system calls (on linux) externally to your application: kill -3 _YOUR_JAVA_PROCESS_ID_ will generation the heapdump.

But I hardly can imagine why would you need such an information. Later in comments you mention 'exact line of code' but these ways are usually external to your JVM... Are you sure you need a line of code that generated heap dump itself, or you're trying to identify the real issue?

Hope this helps

Andere Tipps

In java you create object some where, use it in many places and the let GC to collect it back. There is no single line causing a leak.

What you should look for in tools like MAP is objects count and heap used by them. Pick each of the target class and see why they are not garbage collected. (some one is holding reference more than needed- say a static field )

You may find instructions from this page more useful - http://scn.sap.com/people/krum.tsvetkov/blog/2007/07/02/finding-memory-leaks-with-sap-memory-analyzer (also linked from MAT homepage)

Try to use Java Heap Analysis Tool(jhat) or jconsole (that is in your JAVA_HOME\bin).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top