This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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().