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.

For a school project, I've registered a free VPS on a hosting provider (pipni.cz). It has 256MB RAM:

Mem:    262144k total,   148104k used,   114040k free,        0k buffers

It's running on Debian Squeeze.

I always get this error when I run a Java program:

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

I tried to use Xms, Xmx, Xss with low values and still same result. ulimit -v gives me "unlimited".

My application will be pretty simple and I need to use rmiregistry also. Can somebody help?

share

migration rejected from stackoverflow.com Jan 2 at 17:04

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by ceejayoz, Dennis Kaarsemaker, Ward, Falcon Momot, Ladadadada Jan 2 at 17:04

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – ceejayoz, Dennis Kaarsemaker, Ward, Falcon Momot, Ladadadada
If this question can be reworded to fit the rules in the help center, please edit the question.

    
What version of Java? –  Mark Peters Nov 11 '11 at 17:03
    
Perhaps you could try some other Java implementation, like GCJ (gcc.gnu.org) or Kaffe (kaffe.org) –  Basile Starynkevitch Nov 11 '11 at 17:07
    
Now it should be version from stable repos for squeeze. sun-java6-jre or openjdk-6-jre –  user1042091 Nov 11 '11 at 17:07
    
If you really want a free VM, an EC2 micro instance would have more than twice as much RAM. –  Skyhawk Nov 13 '11 at 17:01

3 Answers 3

Don't use any parameter of Xms, Xmx, Xss and let Java decide. If you need "big" values there, then you need more RAM.

Edit: Just tried it in my VM (256 MB RAM). Works perfectly:

root@Microknoppix:/tmp#  free
             total       used       free     shared    buffers     cached
Mem:        251080     170548      80532          0       3832     125352
-/+ buffers/cache:      41364     209716
Swap:            0          0          0
root@Microknoppix:/tmp#  java -version
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8.7) (6b18-1.8.7-2~squeeze1)
OpenJDK Client VM (build 14.0-b16, mixed mode, sharing)
root@Microknoppix:/tmp#  java HelloWorld
Hello World
root@Microknoppix:/tmp# 
share
    
Executing just java without parameters ends with same errors. –  Mike S. Nov 11 '11 at 21:22
    
Btw, it is 64bit OS. And sorry for this bad formatting, I'm new on SO/SF/etc root@nextquest:~# free total used free shared buffers cached Mem: 262144 147320 114824 0 0 0 -/+ buffers/cache: 147320 114824 Swap: 262144 1800 260344 root@nextquest:~# java -version Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine. –  Mike S. Nov 11 '11 at 21:47
up vote 0 down vote accepted

I know, it's lot of time I ask this question and I don't need solution anymore, but it might help somebody in future. I've figured out, that problem was caused by OpenVZ - and then wasn't big problem to find solution on google (keywords: java openvz).

share
    
My preferred solution is: never use OpenVZ :) –  Michael Hampton Dec 30 '13 at 20:01

I compiled and installed and use java on my FreeBSD system that I have only allocated 64 mb on. blame your problems on Debian bloat

share

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