Message "Could not reserve enough space for object heap" in the JVM

6

So I wanted to know what the limitation is for memory allocation to the JVM depending on the operating system and processor architecture. If you configure it, lower the maximum value of the perm-size to a lower value, can you further increase the Java heap size?

Example:

In Windows 32bits

I had configured Java MaxPermSize with 512m, this allowed me to leave up to ~ 1024m of heap size

Then I changed the Java MaxPermSize to 256m, I got by the heap size up to ~ 1200m.

In Windows 64 with Java Jdk 64bits, you do not have this problem, only if you use JDK 32bits.

If anyone knows of a documentation, please also send a link.

    
asked by anonymous 25.08.2014 / 19:30

1 answer

4

As the limit of 32bits systems is 4GB of RAM and the system needs memory for Swap, kernel among others the practical limit is around 1.4GB to 1.6GB (source) .

Relationship between PermSize and HeapSize :

  

Traditional heap = Objects

     

perm heap = class definitions

In other words, the heap perm is an additional space separate from conventional heap space (for objects). So the bigger the space you set for it, the more space it will take on the system, and this will limit the maximum your system will allow for the conventional heap.

Therefore, the heap is not included in the heap (Xmx), but it can limit it by consuming an additional system space that on a 32bits system will be much more limited than on a 64bits.

Exemplifying: 512Mb + 1024Mb = 1.5Gb (total space your system allowed for the JVM) as you can see is in the range described at the beginning of this answer.

See the official documentation on the oracle site.

The table below shows how to set these options in the JVM

+-----------------+----------------------------------------+---------------------+
| Opção da JVM    | Significado                            | Exemplo             |
| -Xms            | heap size inicial da JVM               | -Xms3072M           |
| -Xmx            | tamanho máximo do heap da JVM          | -Xmx16G             |
| -XX:PermSize    | tamanho inicial do espaço permanente   | -XX:PermSize=128k   |
| -XX:MaxPermSize | tamannho máximo do espaço permanente   | -XX:MaxPermSize=256m|
+-----------------+----------------------------------------+---------------------+

I think it is useful to have this table in an answer about this since I suspect that not everyone knows how to configure such elements     

25.08.2014 / 22:14