Question

I run command in window machine

java -XX:+PrintFlagsFinal -version | findstr /i "HeapSize PermSize ThreadStackSize

and got below value for MaxHeapSize

2118123520

which is 2020MB however, when I call Runtime.getRuntime().maxMemory() , it gives me 259522560 only i.e. 247MB .

Can anyone please suggest why I'm getting this mismatch ?

Was it helpful?

Solution

As per your last comment

I'm using eclipse IDE and didn't change any setting . do you know how to change maximum heap size in eclipse IDE ?

Set the VM arguments found under Run configuration.

VM arguments are typically values that change the behaviour of the Java Virtual Machine (JVM). For example, the -Xmx256M argument allows the Java heap to grow to 256MB.

For more info have a look at Eclipse launching program and VM arguments

enter image description here

OTHER TIPS

Can anyone please suggest why I'm getting this mismatch ?

The Runtime.getRuntime().maxMemory() call is returning the maximum heap size for the current JVM. This is determined by either the -Xmx command line option (e.g. for the java command) or a platform specific default.

The command you are running is giving the maximum allowed value for the -Xmx commandline option on your platform.

Clearly these are different things. Furthermore, the numbers are usually different.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top