• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamically changing -Xmx  RSS feed

 
Victor Ho
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is there a way to dynamically increase the max heap size of a VM after the Java process has been started?

In the case of OutOfMemory exception, I'd like to do a heap dump before exit. But doing a heap dump might require additional memory; looking for a way to possibly increase the heap size on the fly.

Thanks
Victor
 
Arjun K
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Victor,

Its not possible for changing the VM heap or stack memory dynamically. As the Virtual machine will intialize the runtime with the memory limit that you pass on the command line.

Retaining a core dump for out of memory is not possible now; as there will not be enough memory for the virtal machine to retain a core dump in out of memory like situation.

But I can suggest you a crazy idea:
catch the process id of the hung OOME process and pass it on to gcore like tool which will generate a core dump for you to do any post mortem analysis.

May be like this:
gcore 17878 where 17878 is the process id of the hung java process due to oome.

But I have observed a bug which might be fixed in jdk 1.6 which covers your requirement.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6173515

Regards,
Arjun
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!