I ran a test where I just repeatedly created a java string object and freed
its memory. There was no memory leak, meaning that my temporary storage
usage did not increase. On the other hand, there appears to be a memory
leak when doing a similar test in conjunction with creating a spreadsheet.
I found the following on IBM's website about java optimization. I wonder
if I'm dealing with a memory fragmentation issue, and that its affecting
performance also.
Also, look at the difference between the number of objects allocated and
the number of objects freed. If the gap between the two increases over
time, there is a memory leak.
Heap consumption indicating a possible leak during a heavy workload (the
application server is consistently near 100% CPU utilization), yet
appearing to recover during a subsequent lighter or near-idle workload, is
an indication of heap fragmentation. Heap fragmentation can occur when the
JVM can free sufficient objects to satisfy memory allocation requests
during garbage collection cycles, but the JVM does not have the time to
compact small free memory areas in the heap to larger contiguous spaces.
Another form of heap fragmentation occurs when small objects (less than 512
bytes) are freed. The objects are freed, but the storage is not recovered,
resulting in memory fragmentation until a heap compaction has been run.
Heap fragmentation can be reduced by forcing compactions to occur, but
there is a performance penalty for doing this. Use the Java -X command to
see the list of memory options.
From: "Dennis Lovelady" <iseries@xxxxxxxxxxxx>
To: "'RPG programming on the IBM i / System i'"
<rpg400-l@xxxxxxxxxxxx>
Date: 03/23/2010 12:29 PM
Subject: RE: Improving Excel generation performance through calling Java
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
the RPG-Java interface is not optimized somehow. I am religiously
freeing
local references, as the HSSFR4 service program does. In fact, as a
further test, I put the new_String(TempStr) and
hssf_freeLocalRef(TempStr)
back in my procedure, even though they aren't used anymore, and
performance
went back to what is was in the older java code and temporary storage
jumped back up.
As an Amazon Associate we earn from qualifying purchases.