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)
5
  • You cannot change the setting of the JVM heap size at runtime Commented Feb 2, 2011 at 2: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. Commented Feb 2, 2011 at 2:41
  • @Tim Bender - more sad, IMO. You'd have thought that a 10K+ user would have learned to search before firing off a question ... Commented Feb 2, 2011 at 2: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. Commented Feb 2, 2011 at 3:16
  • 1
    If jinfo could do it, then spawn jinfo would be a correct answer to those other questions. Commented Feb 2, 2011 at 3:26

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.