Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

prgramatically generating a heap dump

 
Stuart Rogers
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic