Domanda

Suppose you get Java heap dump to analyze memory leak (after -XX:+HeapDumpOnOutOfMemoryError or from non-controlled party).

How can I reduce object count in dump by calling some GC process, which in any case be cleaned by GC after dumping process?

È stato utile?

Soluzione 3

Seems that Eclipse Memory Analyzer Can I run Java garbage collection against a heap dump file? do that:

By default unreachable objects are removed

@Guntram Blohm. As you say the reason for OOME is out of memory or storage manager was unable to reclaim enough memory. In case if you require long array for fragmented memory it is possible that GC isn't performed at all!

Altri suggerimenti

Java will only throw an out of memory error if, after GC, there's still not enough space. So, there's no object count to reduce, every object in your heap is still reachable from somewhere or it would have cleaned by the GC that precedes the OOM Error.

Possible solutions;

  • reduce the heap size when investigating a memory leak. This produces a smaller dump.
  • use a commercial tool like YourKit which doesn't need as much memory to analyse a heap dump.
  • use more memory. You can buy 32 GB for about $400.

You can't dump the PermGen and your dump has only reachable objects or you wouldn't have got an OOME in the first place.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top