Why does the java -Xmx not working?
Posted
by
Zenofo
on Server Fault
See other posts from Server Fault
or by Zenofo
Published on 2012-12-04T11:05:11Z
Indexed on
2012/12/04
11:12 UTC
Read the original article
Hit count: 283
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?
© Server Fault or respective owner