1

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)
Community
  • 1
  • 1
Ken Bloom
  • 57,498
  • 14
  • 111
  • 168
  • [You cannot change the setting of the JVM heap size at runtime](http://stackoverflow.com/questions/763295/setting-jvm-heap-size-at-runtime) – Mark Elliot Feb 02 '11 at 02:21
  • @Stephen C, I think it is funny to no end that you suggest closing this as a duplicate of another question which contains a suggestion to close as a duplicate of yet another question. Whilst @Mark Elliot indicates (4 minutes before you, I might add) that this question is a duplicate of yet a fourth question. – Tim Bender Feb 02 '11 at 02:41
  • @Tim Bender - more sad, IMO. You'd have thought that a 10K+ user would have learned to search before firing off a question ... – Stephen C Feb 02 '11 at 02:50
  • @Stephen: I did search. I saw both of those questions, and felt that they did not answer some of the specifics that I'm asking in this question. A lot of the discussion on those questions is focused on the idea of a JVM changing its maximum heap size from the inside (which is related to the security policy of the JVM, whereas changing it from the outside may very well be the administrator's perogative) and I added the specific question about using `jinfo` to do so, and the Debian bug. – Ken Bloom Feb 02 '11 at 03:16
  • 1
    If `jinfo` could do it, then *spawn jinfo* would be a correct answer to those other questions. – Ben Voigt Feb 02 '11 at 03:26

1 Answers1

2

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.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216