Monday, April 12, 2010

Java Notes API prints "PANIC: Insufficient memory."

Problem:
A Java application using the Java Notes API (for IBM Domino server) printed:

Thread=[1934:0002-193C]
Stack base=0x0032EB34, Stack size = 1248 bytes PANIC: Insufficient memory.

when it was reading and writing to a large size NSF file ~2GB .

Solution:
setting the JVM maximum heap to 200MB with "-Xmx200m"

Why this resolve the issue?
When launching a JVM without "-Xmx" parameter the JVM set it to a default value which on Windows platform is half of the real memory.
As the machine had 3.5 GB RAM , it means the JVM tried to reserve 1.7 GB for the process.
The Java Notes API uses the process shared memory to handle the nsf.
it PANIC when it could not allocate more memory, as 1.7 GB of process memory space was already reserved by the JVM.

What facts suggested the cause?
The domino server NSD contained the following:
COMMIT RESERVED TOTAL
PRIVATE: 25.1M 1.7G 1.7G
MAPPED: 174.9M 4.5M 179.4M
IMAGE: 56.1M 0.0K 56.1M
TOTAL: 256.1M 1.7G 2.0G
which indicated that the memory was reserved by the Java application and not by the Java Notes API