File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RuntimeMXBean

 
vladislav peichev
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Pie
Posts: 1059
24
Android C++ Java Linux PHP Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic