Error occurred during initialization of VM

If  you are facing following error when restarting the tomcat service or check the java version on the server.
===============================
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
===============================
then  you need to increase the java heap size by using following commnad.
root@server [/]#export _JAVA_OPTIONS="-Xms20m -Xmx64m -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:NewSize=10m -XX:MaxNewSize=10m -XX:SurvivorRatio=6 -XX:TargetSurvivorRatio=80 -XX:+CMSClassUnloadingEnabled -XX:+CMSClassUnloadingEnabled"
Then restart the tomcat service on the server.
If you are facing same problem again and again on the server then add the following code into /etc/profile file.

Quote:
#cPanel Added Limit Protections — BEGIN
#unlimit so we can run the whoami
ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
LIMITUSER=$USER
if [ -e “/usr/bin/whoami” ]; then
LIMITUSER=`/usr/bin/whoami`
fi
if [ “$LIMITUSER” != “root” ]; then
ulimit -n 100 -u 20 -m 200000 -d 200000 -s 8192 -c 200000 -v 200000 2>/dev/null
else
ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
fi
#cPanel Added Limit Protections — END

Save and exit from the file and then logout from the server and login again and try to check the java -version .

Leave a Comment