This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes prgramatically generating a  heap dump Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "prgramatically generating a  heap dump" Watch "prgramatically generating a  heap dump" New topic
Author

prgramatically generating a heap dump

Stuart Rogers
Ranch Hand

Joined: Oct 02, 2008
Posts: 133
Greetings all,

I'm trying to hunt down what's causing the dreaded "OutOfMemoryError : heap space" error in my monster (standalone desktop Java/Spring3x/Hibernate3x/AtomikosJTA/Maven/MySQL5x/Swing/Eclipse app) . I see where you can place -XX:+HeapDumpOnOutOfMemoryError and -XX:+HeapDumpOnCtrlBreak as VM arguments . Not sure what effect the latter would have when executing from within an IDE. So is there a snigglet of code that will trigger a heap dump like System.gc() triggers garbage collection? And if the code hits the trigger repeatedly do you wind up with several unique snapshots (presumably timedatestamped) or would the trigger write over the previous dump?

TIA,

Still-learning Steve
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9962
    
163

Apparently, you can do it but will require reference to a vendor specific Java class and MBean name https://blogs.oracle.com/sundararajan/entry/programmatically_dumping_heap_from_java

[My Blog] [JavaRanch Journal]
 
Don't get me started about those stupid light bulbs.
 
subject: prgramatically generating a heap dump
 
Similar Threads
does java 7 support -XX:+HeapDumpOnCtrlBreak
Spring web flow Out of Memory issue
Getting java.lang.outofmemoryexception
issue while server startup
OutOfMemoryError debugging