I want to capture the objects that are getting collected during the System GC that occurs when I generate a heap dump. Is there a way to disable that System GC?
-
Which JVM are you using? – Aleš Jan 02 '13 at 21:41
-
IBM, sorry, I should have noted that. Though I did tag it as WebSphere... :) – Greg Jan 04 '13 at 16:34
-
A similar post here: [How can I take a heap dump on Java 5 without garbage collecting first?](http://stackoverflow.com/questions/1268336/how-can-i-take-a-heap-dump-on-java-5-without-garbage-collecting-first) – Kurtcebe Eroglu Jan 06 '13 at 19:53
4 Answers
You can generate "system dump" instead of "heap dump". I haven't found any documentation on that, but I just tried and it seems that "system dump" doesn't trigger "system GC".
The "system dump" can be requested with generateSystemDump
JMX operation. If you prefer to use kill -3
command, then you'll probably need to add an environment variable to your JVM:
JAVA_DUMP_OPTS=ONDUMP(SYSDUMP)
The "system dump" needs to be processed with jextract
tool before loading to Eclipse MAT. System dump is also much larger than heap dump, mainly because it contains not only object tree, but also the actual object data.

- 2,840
- 1
- 17
- 17
-
... and the list of objects you're looking will be accessible via "Unreachable Objects Histogram" in MAT. – Marcin Płonka Jan 03 '13 at 11:39
-
-
@MarcinPłonka is this generateSystemDump JMX operation is only native to WebSphere Application Server? – zygimantus Oct 02 '20 at 22:55
In an IBM JRE you can disable explicit GC by adding -Xdisableexplicitgc
as a JVM argument. However based on this article there seems that this argument will not help.
Maybe a PMR to IBM support would help.

- 2,192
- 1
- 22
- 39
Considering Hotspot, there are no parameters influencing the behavior of the VM when dumping a Heap. Usually, a GC collection is triggered before dumping a heap.
You can at least enable class histograms printing before/after a Full GC - this way you will see which objects were collected. (XX:+PrintClassHistogramBeforeFullGC -XX:+PrintClassHistogramAfterFullGC
)
You can also try -XX:+DisableExplicitGC
but I do not think this will help. When I collect a heap dump I always notice some objects being collected.

- 8,896
- 8
- 62
- 107
Just came across this post and I thought I'd put my two bob in. You can generate a system core via the WebSphere Adminconsole: Navigate to Troubleshooting > Java dumps and cores. Select the server(s) to collect dumps from. Click on System Dump to produce a system core.
You also don't need to jextract the system core if you only need to do heap memory analysis in MAT. The system core also has a lot more useful diagnostic data than a heapdump,most times you can see the stack of the thread that is leaking heap memory

- 1