I bumped into a weird issue.
I have a machine with 32GB of RAM. For scale testing purposes I wrote a program that spawns multiple instances of some application in a different class loader. My aim is to host 1000 instances on the same application in 1 process. I tackled this task gradually. I was able to host up to 800 instances without a problem.
When I increased to 1000 instances I get an out of memory error. See the following file for the full log hs_err.log.
As you can see my program fails to allocate from the Metaspace. This consistently happens when the Metaspace reaches around 1 GB of memory. According to Java documentation the Metaspace area is not limited and my machine has enough memory to accomodate more than 1 GB of metaspace.
when my process crash I see the following message:
mmap failed for CEN and END part of zip file
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00007f5056e7c000, 12288, 0) failed; error='Cannot allocate memory' (errno=12)
There is insufficient memory for the Java Runtime Environment to continue.
Native memory allocation (mmap) failed to map 12288 bytes for committing reserved memory.
An error report file with more information is saved as:
/opt/itzik/multirunner-1.0.0/hs_err_pid8568.log
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00007f50570c6000, 262144, 0) failed; error='Cannot allocate memory' (errno=12)
[thread 139989735913216 also had an error]
mmap failed for CEN and END part of zip file
mmap failed for CEN and END part of zip file
[thread 139984035763968 also had an error][thread 139985862088448 also had an error]
[thread 139983882610432 also had an error]
My questions are:
- Is there some undocumented limit to the Metaspace size (by chance it is 1 GB)?
- Is there some limit to the number of Classloaders my program can use?
- Do you see some other clue that explains why my program crashes from the attached file?
Thanks