jcorreia

Well-Known Member
Apr 25, 2005
53
0
156
HI,
I´m running in my dedicated server a xmpp java server - openfire.
Yesterday I´ve upgraded from cpanel 11.23 to the last stable 11.25. Openfire was running smootly in my server(with 2G of RAM) for 3 years,
but yesterday when I tried to reboot I´ve come across an error stating

"Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine."

I was trying to run it as root, so I think it´s not user permissions or limits.
I´ve managed to start it changing in /etc/sysconfig/openfire

to OPENFIRE_OPTS="-Xmx64m"

Normally it was OPENFIRE_OPTS="-Xms32m -Xmx192m".

After a server restart I´ve managed to do an openfire restart with the memory it was always configured (192m).

It´s the first time I´ve come across this error, so I supposed it´s in some way related to the cpanel upgrade.

After some research I´ve found that it could be related to fork bomb in WHM, but I always had it turned off.

I´ve read in another forums(from people that have problems with tomcat anf other java servers) that a possible solution to this in cpanel
is to add the following code in the start of the /etc/profile file.

PHP:
#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
from here Could not reserve enough space for object heap - UK Web Hosting | Dedicated Server and VPS Forum

But there some other solutions here
NGASI Installation and Administration


My question is ? did something changed from 11.23 to 11.25 that could introduce java server problems ?
Do you advice that solution in etc/profile ? Is there another better solution ?


Thanks,
Jorge Correia
 
Last edited:

qwidjib0

Member
PartnerNOC
Aug 3, 2005
15
0
151
Chicago, Illinois
Memory issues with the JVM are incredibly common in Java hosting. Some things you might consider throwing into /var/cpanel/tomcat.options

-Xms1024M
-Xmx1024M
-XX:MaxPermSize=768M
-XX:NewSize=256m
-XX:MaxTenuringThreshold=0
-XX:+UseTLAB
-XX:+UseConcMarkSweepGC
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
Word of caution when doing this, however- if you give memory resources to the JVM, they will be taken away from the rest of the server; so don't set them too high.