Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I bought a vps for hosting my java needs. But I can't run java on it. Everything about java is correctly installed but when I try to run java ("java -version" forexample) I get this error :

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

I don't think this is a java centered problem, Out of memory for sure. I contacted the vps admin, but he says everything is fine, you have 2gb ram, expandable to 4gb! I did a bit search on the subject, here is my BEANS file (numbers converted to humanredable form using a script). By the way do JVM heap memory allocs count on kmemsize or privvmpages ? How much ram does that configuration allows me to allocate with jvm for a single process?

resource                     held              maxheld              barrier                limit              failcnt
kmemsize                  2.25 mb              2.35 mb             13.71 mb             14.10 mb                    0
lockedpages                     0                    0           1024.00 kb           1024.00 kb                    0
privvmpages              20.54 mb             21.33 mb            256.00 mb            272.00 mb                  156
shmpages                  5.00 mb              5.00 mb             84.00 mb             84.00 mb                    0
numproc                        13                   14                  240                  240                    0
physpages                 9.36 mb              9.45 mb                    0            MAX_ULONG                    0
vmguarpages                     0                    0            132.00 mb            MAX_ULONG                    0
oomguarpages              9.36 mb              9.45 mb            MAX_ULONG            MAX_ULONG                    0
numtcpsock                      3                    3                  360                  360                    0
numflock                        3                    3                  188                  206                    0
numpty                          2                    2                   16                   16                    0
numsiginfo                      0                    1                  256                  256                    0
tcpsndbuf                69.17 kb             69.17 kb              1.64 mb              2.58 mb                    0
tcprcvbuf                48.00 kb             48.00 kb              1.64 mb              2.58 mb                    0
othersockbuf              6.80 kb              6.80 kb              1.07 mb              2.00 mb                    0
dgramrcvbuf               0.00 kb              0.00 kb            256.00 kb            256.00 kb                    0
numothersock                    9                   10                  360                  360                    0
dcachesize                0.00 kb              0.00 kb              3.25 mb              3.46 mb                    0
numfile                       704                  746                 9312                 9312                    0
numiptent                      10                   10                  128                  128                    0

Thanks in advance!

share|improve this question

3 Answers 3

You should try JRockit VM it is work perfect on my OpenVZ VPS, it consumes memory much less then Sun/Oracle jvm.

share|improve this answer

I had a similar problem when I was hosted at VPSLink, the Sun/Oracle JVM just doesn't work with OpenVZ (you can search the old threads on the VPSLink forums to get more informations).

In the end, the only thing that worked for me on the OpenVZ container was the IBM JDK, which you can get at https://www.ibm.com/developerworks/java/jdk/linux/download.html

I think however that a better solution would be moving to a dedicated server where you can install the JDK you want and get much less headaches than with OpenVZ.

share|improve this answer

Doublecheck if your script translated the raw beancounters correctly. according to this you only have 256 megs of RAM, not 4 gigs as your admin tells you.

concentrate only on 2 beans:

  • privvmpages - maximum amount of memory your container can allocate (reserve)
  • oomguarpages - guaranteed amount of memory your container will get to actually use. In case of tight memory situation on the host everything using over that amount will probably be killed.

Java is notorious for allocating gobs of memory and then never using them, counting on the OS to overcommit. In my experience you need at least a gig of privvmpages to run JVM reliably, although only couple of dozen megs will be used.

After couple of months experimenting and trying to contain privvmpages in VEs running Java, I have personally given up, I just set the barrier to the max and tweak the oomguarpages appropriately and hope for the best ;)

share|improve this answer
    
Thank you Aleksander. I am a java developer, my first time with a VPS. Well it wouldbe enough if i had some swap, but seems like i can't even use swap =). The real problem is that I don't even use 256mb's. I use java's -Xmx parameter. Even with -Xmx96m (which gives 96m heap to jvm at most) I get oom. And I noticed that physpages bean tells how much I really use ram. For this example 9mb physpages is ridicilous ofc. By the way script is correct, checked with hand. –  Ginnun Aug 7 '10 at 22:47
    
unfortunately, if you dont get your admin to give you more privvmpages, you are screwed, thats how JVMs are. It is not just heap that they reserve, here is one real time example from 'top', where you can see that although -Xmx is 128 megs, java took 437 megs of virtual memory anyway PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 13345 be 21 0 437m 194m 11m S 0.0 19.0 0:53.48 /usr/local/java/bin/java -Xmx128M -XX:MaxPermSize=128m ... –  Aleksandar Ivanisevic Aug 10 '10 at 10:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.