Can't launch jstat : Could not reserve enough space for object heap

127 views Asked by At

I have an old Jboss server, with 5go of RAM. My java app is configured like that :

...-server -Xms3200m -Xmx3500m -XX:MaxPermSize=512M...

When I try to shutdown, it uses the same JAVA_OPTS as the start, so it fail. So I modify the shutdown.sh script, and add :

...
JAVA_OPTS='-Xms128m -Xmx128m -XX:MaxPermSize=128m'
export JAVA_OPTS
...

Everything works fine. But now, it's my JMX stats which don't work anymore, I assume they uses jstat to mesure the free heap.

When I do a :

./jstat -gccapacity PID

I have the message :

Could not reserve enough space for object heap

But I have 1go of RAM free on the server at this time ! What JAVA_OPTS jstat use work ?

1

There are 1 answers

1
JohannesB On BEST ANSWER

Most Java implementations that I worked with use a default Max Heap Size of 25% of system memory and your system probably does not allow overcommit of memory so this might cause this issue. (Source: https://docs.oracle.com/javase/7/docs/technotes/guides/vm/gc-ergonomics.html )

I hope this helps solve the issue:

For jstat you can set -Xmx but you need to prepend -J in front of it like:

jstat -gccapacity $YOUR_JBOSS_PID -J-Xmx10m -J-Xms10m -J-XX:+PrintFlagsFinal

PrintFlagsFinal will show you the effective settings that the JVM will start with, look for: MaxHeapSize for the effective value set by -Xmx or the equivalent: -XX:MaxHeapSize=128m

Source: https://docs.oracle.com/javase/7/docs/technotes/tools/share/jstat.html

Let me know it that helps (and if not, please provide some details like: java -version and uname -a )

See for more info and/or options also: https://chriswhocodes.com/vm-options-explorer.html