I have a .jar which is run internally in NX. This code uses POI (Java API for Microsoft documents) to read data from xlsx. I put the POI jars inside a lib folder and modify the Manifest file to ensure that the .jar is able to find the relevant classes.
In this case I kept getting OutofMemory error (PermGen Space) after a few executions. I modified the UGII_JVM_OPTIONS to increase the heap / PermGen Space. This did not help.
I used Jconsole / Visual VM to monitor the memory usage of the JVM initialized by NX. It most certainly does run out of Non-Heap memory space after a few executions. I did not succeed in figuring out what are the classes that the JVM holds on to which GC cannot clean it up.
Next up was, UGII_CLASSPATH_PRELOAD. I used this to ensure that JVM gets initialized with the required POI libraries. I removed the classpath argument in my manifest file and did not include lib/POI jars in my final jar packaging. Works like a charm ! Jconsole / Visual VM shows that the Non-Heap memory usage around 50% from JVM initializing to until I terminate the NX session. I also wrote a dll to simulate multiple execution of the jar file (theSession.Execute(library name etc.,)...Looped it for 100 executions !). Non-Heap memory usage stays at 50%
So I think the POI jars are not unloaded "IMMEDIATELY" even though my NXOPEN java program does. A successful run clearly shows in the syslog that the .jar (mine...not the POI) has been unloaded.
My question is, Is this the right way to do this? Some how I am not comfortable with preloading the POI jars. I come from a .net world where I use unload "IMMEDIATELY" option religiously