unable to allocate enough memory

On SunOS 5.8 I get an error when starting a large Java process with over 2Gb memory.

Error occurred during initialization of VM
Could not reserve enough space for object heap

When stopping several other Java processes we can start this process. This seems to indicate that we don't have enough consecutive memory blocks available.

top reports the following:

load averages:  0.81,  0.91,  1.26                                   17:03:16
284 processes: 283 sleeping, 1 on cpu
CPU states: 90.4% idle,  6.0% user,  2.4% kernel,  1.1% iowait,  0.0% swap
Memory: 32G real, 11G free, 28G swap in use, 2491M swap free

Thus even though we have 11Gb out of 32Gb free on our 6CPU system we can't allocate enough memory.

uptime reports:

5:13pm  up 237 day(s), 9 min(s),  19 users,  load average: 0.93, 1.16, 1.27

Is it possible that the memory is too fragmented? How can we tell? or how can we fix this?

I think increasing the available memmory to JVM would be enough. Add these parameters to the command line:

java -Xms256M -Xmx512M  ....

This way, a min. of 256Mb to a max. of 512Mb will be available. Change the values acording to your needs and tell us if it worked :wink:

Regards.

We have 2Gb heap allocated. The issue is not a java issue because this is an OS message produced on the native stdout, not SystemOut from java. The Solaris system is unable to allocate enough memory for the JVM, even though it reports to have 12Gb available. If we stop other large memory consuming processes it is possible to start this JVM process. How is it possible that Solaris can't allocate 2Gb to 3Gb memory when there's 6 times that much available?

I'm afraid I misunderstood your first post, I'm sorry.
That's a little bit weird... I'm talking about the fact that when you stop other java processes it works...

  • Is your JVM 32 bits?
  • what about "ulimits"?

Sounds like a 32 bit constraint on process space.

ulimit -a reports:

core file size (blocks)     unlimited
data seg size (kbytes)      unlimited
file size (blocks)          unlimited
open files                  1024
pipe size (512 bytes)       10
stack size (kbytes)         8192
cpu time (seconds)          unlimited
max user processes          29995
virtual memory (kbytes)     unlimited

It is a 32-bit JVM:

java version "1.4.2_15"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_15-b02)
Java HotSpot(TM) Client VM (build 1.4.2_15-b02, mixed mode)

uname -a:

SunOS hostname 5.8 Generic_117350-43 sun4us sparc FJSV,GPUZC-M

We can restart the other processes afterwards as well.

I don't know anything about Java, but what about memory fragmentation, could that be an issue?

It could, but how would I be able to tell? Or to solve it?

how much swap space do you have?
I think I've read somewhere that you might need some amount of swap space available when using large amounts of heap...

This apparently is a problem on SunOS

Read post #2 here
Java Virtual Machine (JVM) - Error -unable to create JVM,Could not reserve enough space for object heap

It suggests further reading to solve the problem.

Turns out the amount of available swap space was the issue. The message is that the system is unable to reserve enough swap space.

Java Virtual Machine (JVM) - unable to allocate enough memory