Change java -Xmx after the VM has already started

2k views Asked by At

Possible Duplicates:
Setting JVM heap size at runtime
programatically setting max java heap size

I have a long-running Java job running on my computer, and it's slowing down immensely when it gets near the end becuase it encounters serious memory pressure and the garbage collector has to run frequently. In other words, I underestimated the maximum heap size -Xmx that I need for this job.

Since I don't want to restart the job, is there any way to make the JVM change it's maximum heap size after the JVM has already started, for example using jinfo -flag or something like that? Is this possible?

I've been trying with variations on jinfo -flag +Xmx1024m or jinfo -flag Xmx=1024m, and they all give me the following exception. Is this a symptom of Debian bug #532538 (I am using the affected version of the JVM), or is this the expected behavior (and it's just impossible to change -Xmx later), or am I providing the flag to jinfo incorrectly?

Exception in thread "main" java.io.IOException: Command failed in target VM
    at sun.tools.attach.LinuxVirtualMachine.execute(LinuxVirtualMachine.java:218)
    at sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:213)
    at sun.tools.attach.HotSpotVirtualMachine.setFlag(HotSpotVirtualMachine.java:190)
    at sun.tools.jinfo.JInfo.flag(JInfo.java:129)
    at sun.tools.jinfo.JInfo.main(JInfo.java:76)
1

There are 1 answers

0
Stephen C On BEST ANSWER

Since I don't want to restart the job, is there any way to make the JVM change it's maximum heap size after the JVM has already started, for example using jinfo -flag or something like that? Is this possible?

No. It is not possible. Or at least, not with any existing Sun JVM on any platform.

For more details, see the answers to the related questions per the comments above.

Is this a symptom of Debian bug #532538 ?

No.