This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes RuntimeMXBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "RuntimeMXBean" Watch "RuntimeMXBean" New topic
Author

RuntimeMXBean

vladislav peichev
Greenhorn

Joined: Apr 28, 2011
Posts: 22
I try to verify Java heap size inside an applet running in XHTML page using the following code :

However sometimes (1 in 10-15 loadings of the applet) the list does not contain -Xmx parameter and result variable has value of zero. Does anybody have an idea why does this issue occur and is there a possible solution. Thanks in advance.
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 497
    
    5
The -Xmx arg is not mandatory, but JVM always has a max heap value. Instead of relying on command line args to infer max heap, you can get a MemoryMXBean using ManagementFactory.getMemoryMXBean() and use its getHeapMemoryUsage().getMax().
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RuntimeMXBean