4

I have an application running on a browser (IE if it matters) on a not yet activated windows (if that matters). I have set the environment variables in the JVM control panel to be -Xms5m -Xmx5m (I have also done -Xms16m and -Xmx16m).

When I run the application and monitor the pid of the process using jconsole it tells me I am using significantly more than my set heap rather than throwing a out of heap space error (I am trying specifically to get this error). It uses 15-20Mb according to jconsole. I have rebooted my computer and I have set this option with all of my browsers off.

Does anyone know why the parameters are being ignored.

Let me know if there is any information missing.

Just a note, jconsole specifically says that my heap memory usage is 20mb. I am quite aware that there may be more memory used due to the loading of the JVM, libraries, stack, etc. The issue I am having is that the heap is exceeding the heap size I am specifying should be used.

The -Xmx16m option is not being listed in Java VisualVm even when it is the only option being set in the environmental variables (I have even removed -Xms16m to make sure that Java VisualVm is being updated. -Xms16m does appear though even though -Xmx16m doesn't). Does anyone know why this might be the case?

I have tried Java RE version 6 from 27 to 31 and all of them are missing the Xmx option in the Java VisualVm option and all of them only have -Xms16m.

Jason Zhu
  • 2,194
  • 3
  • 23
  • 27
  • How you are passing the values ? – Bhavik Ambani Aug 03 '12 at 18:28
  • I passed the values by opening control panel, searching for java and choosing it, then going to the java tab and click the view button, and finally setting the Runtime Paramaters (then ok, apply, shut down browsers, restart computer, etc). – Jason Zhu Aug 03 '12 at 18:34
  • Possible duplicate of http://stackoverflow.com/questions/6450132/java-seems-to-ignore-xms-and-xmx-options – kgautron Aug 03 '12 at 18:41
  • 1
    Possible duplicate of http://stackoverflow.com/questions/5026376/applet-java-heap-space – viking Aug 03 '12 at 18:43
  • 3
    In VisualVM you can see the command line arguments and the maximum heap size of a running process (to confirm its being ignored) – Peter Lawrey Aug 03 '12 at 18:53

1 Answers1

3

As has been answered many times (I can't find the link at the moment), the runtime parameters control only how much memory your program is allowed to allocate from the heap. The JRE itself uses much more memory to manage the heap, so the -Xms and -Xmx parameters do not correlate well (if at all) to the amount of actual memory used by your program.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
  • I am using jconsole to check for heap memory usage and it is possible that jconsole is giving me an incorrect reading but an emulated terminal that I am using with the application is telling me the same information. What other tools would you recommend that I use to check heap memory usage? – Jason Zhu Aug 03 '12 at 18:51
  • 2
    I don't think your exasperation is appropriate. He's using JConsole to determine the size of the heap. JConsole should be accurate, suggesting there is indeed a problem with passing on the JVM configuration parameters. – Confusion Aug 03 '12 at 18:52