Limit Java Heap Space for play framework globaly

Viewed 27703

I have a very old linux system and installed java and play framework. When I run java I get:

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

So I limited the java heap space in application.conf:

jvm.memory=-Xmx256M -Xms256M

With that setting I can run play test, play run etc....

But I cannot run:

play dependencies 
~        _            _ 
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/   
~
~ play! 1.2.1, http://www.playframework.org
~
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

Is there a global configuration file or environment variable where I can limit java heap space globaly for play framework?

Update: Also the following is not working:

play dependencies -Xmx256M -Xms256M
~        _            _ 
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/   
~
~ play! 1.2.1, http://www.playframework.org
~
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

Update 2:

Memory:

ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
pending signals                 (-i) 1024
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 38912
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Limits:

cat /proc/meminfo 
MemTotal:      4139312 kB
MemFree:        332988 kB
Buffers:        105252 kB
Cached:        1705644 kB
SwapCached:          4 kB
Active:        2566216 kB
Inactive:       625032 kB
HighTotal:      786432 kB
HighFree:         1728 kB
LowTotal:      3352880 kB
LowFree:        331260 kB
SwapTotal:     4192956 kB
SwapFree:      4168224 kB
Dirty:             368 kB
Writeback:           0 kB
Mapped:        1672180 kB
Slab:           570864 kB
CommitLimit:   6262612 kB
Committed_AS:  4075144 kB
PageTables:      19884 kB
VmallocTotal:   303096 kB
VmallocUsed:     10400 kB
VmallocChunk:   292648 kB

BR,

Rene

9 Answers

Just ran into this on my laptop running Fedora and using Play 2.0 when simply starting the interactive shell. I found that the build script is setting the memory values by default to pretty high values.

To fix this I had to edit the $play_dir/framework/build script and change the values manually, at the end of the script it does the following to launch:

java ${DEBUG_PARAM} -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M ...

Just change the -Xmx/-Xms values (and possibly the permgen) accordingly.

In Play 2.2 and Java 7, this is what I used.

$ target/universal/stage/bin/foo -mem 256 -J-server

For the detail of -mem, please see:

$ target/universal/stage/bin/foo -h
Related