6

I am trying to use java in an environment where the virtual memory is limited to 2GB by ulimit -v 2000000 but I get memory errors. Running java -version in this environment gives:

$ java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

No matter how low I set -Xmx, I cannot get java to run under this environment. However, if ulimit -v is set to 2.5GB, then I can set -Xmx to 250m, but no higher.

$ java -Xmx250m -version
java version "1.7.0_19"
OpenJDK Runtime Environment (rhel-2.3.9.1.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

$ java -Xmx251m -version
#
# There is insufficient memory for the Java Runtime Environment to continue.
# pthread_getattr_np
java version "1.7.0_19"
OpenJDK Runtime Environment (rhel-2.3.9.1.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)# An error report file with more information is saved as:
# ~/hs_err_pid12079.log

Is it possible to use java in an environment where ulimit is used to limit the virtual memory?

sina72
  • 4,931
  • 3
  • 35
  • 36
Barry Hurley
  • 567
  • 1
  • 5
  • 18
  • 1
    Seems like the system is already consuming most of the available memory and Java gets no room the breathe. The fact that it starts to work when you provide more breathing space proves that. So yes - it is possible, but not when you have no resources actually available. – Gimby Nov 11 '13 at 16:20
  • This is not the issue. `top` shows over 7GB of free RAM and I can run python and C/C++ programs that allocate memory up to 2GB. – Barry Hurley Nov 11 '13 at 16:49
  • 1
    Are you sure you used `ulimit -v 2000000` and not `ulimit -v 200000`? – Holger Nov 11 '13 at 19:30

1 Answers1

3

This is a well known giant bug in all available JVMs (oracle or openjdk, version 6,7,8). Reported here: https://bugs.launchpad.net/ubuntu/+source/openjdk-7/+bug/1241926 https://bugs.openjdk.java.net/browse/JDK-8071445

Unfortunately without solution by the Java developers. Solution: Play desperately with the various java options or stop using java and java based applications :-(

Martin
  • 96
  • 5