Following error happens if I call java or javac:
Error occurred during initialization of VM
Could not reserve enough space for object heap
#
# An unexpected error has been detected by Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0xb7dee4da, pid=9915, tid=3084225424
#
# Java VM: Java HotSpot(TM) Client VM (10.0-b22 mixed mode linux-x86)
# Problematic frame:
# C [libc.so.6+0x6f4da] cfree+0x7a
#
# An error report file with more information is saved as:
# /root/hs_err_pid9915.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
Aborted
As far as I read, the problem is supposed to be that java tries to allocate a continuous chunk of memory, and this doesn't work in some virtual environments (Xen, openVZ and others).
Is there a solution for this problem?
Java works fine in Xen -- I'm running a big Solr instance on a Xen VM right now. It also works on OpenVZ (been there, done that), although it does require some tweaking due to OpenVZ's "interesting" allocation limits model. Basically, whatever you're reading, it's massively and completely wrong.
Things to check include:
/proc/sys/vm/overcommit_memory
set to 2? That will prevent overcommit from working, which is the core of what Java is trying to do.Java certainly works on Xen. It might be that you don't have enough physical(+swap) memory to start the JVM. Xen domains tend to be constrained by the amount of memory they have. 128MB or 256MB is fairly common for commercial VPS providers. The JVM uses two parameters to set the initial size and maximum size of the heap. These are -Xms and -Xmx respectively. IIRC the default for -Xmx is (or at least was) 64M. If -Xms is configured, the JVM will attempt to allocate that much memory at startup. It's a common trick to set both values to the same value to stop memory fragmentation. Setting -Xms to a value higher than you physically have available would probably cause you some problem. I would try creating a simple Hello World java program and see if you can run something like:
and see if that works. Try reducing the values lower if it doesn't work; raise it if it does. Hopefully you can discover how much memory you can use.