Why does the java -Xmx not working?
- by Zenofo
In my Ubuntu 11.10 VPS, Before I run the jar file:
# free -m
total used free shared buffers cached
Mem: 256 5 250 0 0 0
-/+ buffers/cache: 5 250
Swap: 0 0 0
Run a jar file that limited to maximum of 32M memory:
java -Xms8m -Xmx32m -jar ./my.jar
Now the memory state as follows:
# free -m
total used free shared buffers cached
Mem: 256 155 100 0 0 0
-/+ buffers/cache: 155 100
Swap: 0 0 0
This jar occupied 150M memory.
And I can't run any other java command:
# java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
# java -Xmx8m -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
I want to know why the -Xmx parameter does not take effect?
How can I limit the jar file using the memory?