Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RuntimeMXBean

 
vladislav peichev
Greenhorn
Posts: 22
  • 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: 1192
25
Android C++ Java Linux PHP Python
  • 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().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic