Well, I was merrily fine tuning the VM parameters to see if I could extract any more juice out of the VM, when I kept bumping into an OOM error. Would appreciate if someone could figure out what/where the problem is: hope to Heavens it is somewhere in my code or logic, and not in the VM (kinda unlikely, right !) and definitely not with Java3D (since the support for it is a little dry now).
The issue seems to be simply that if I run the GC manually before I create and display an object, then I don’t get an OOM error; if I don’t invoke the GC, however, then an OOM error does get triggered. Is that possible at all ? Some more details below:
After I launch my app. and create/delete an object of the same class and run the gc repeatedly, the base level memory for just the app. is about 22M, my Xmx and Xms memory being 128M. Next, I successively create 3 objects and the “used” memory levels are 56M, 91M, and 118M. With the used memory at 118M, I delete 2 of the objects(actually one of them should do I think). The used memory level still remains at 118M or so. Now, with just one object remaining on the canvas, if I try to create a new one then an OOM error happens. If before creating the object, however, I run the gc a few times then the used memory falls to ~85M which is quite well sufficient for me to create that extra object and, expectedly, the creation subsequently succeeds without an OOM error.
I’m using the MemoryMonitor.java code that comes along with the java2d demo bundled with the Java sdk. The used memory, IIRC, is computed as runtime.totalMemory() - runtime.freeMemory(), the former being synonymous with Xmx size I assume. I should also add that there is a memory leak in Java3D for the object parameters that I’m using but that appears to have been taken care of with my own workaround. I say this because after each object creation and deletion, running the gc gets the memory level back to expected base values.
TIA
Edit: Forgot to mention that my j2sdk is 1.4.2_03 and Xmx and Xms are the only VM parameters I’m using. The benchmark machine has 256M of RAM, and the virtual memory is handled by windows.