Garbage Collect J3D Resources
I am trying to figure out how to reclaim the resources generated from a Java3D program in general and from a Texture specifically. I have a spike solution shows a simple textured sphere on a Canvas3D. Once I dispose of the JFrame containing the Canvas3D I would expect all resources to be garbage collected sooner or later. Instead, it appears that only some items are GC'd and others are not(In particular, I think textures are not). When I profile the program using NetBeans, I get a large number of leftover character arrays and hashmap entries, which I assume are in the J3D objects.
My spike solution has a panel that dumps memory state every 5 seconds and buttons to allocate the Canvas3D JFrame and to force garbage collection. When I run it, I generally get results something like this:
Initial state: ~0-2 MB Heap Used
After allocation: ~28 MB Used
After initial allocation: ~15 MB Used
After JFrame disposal and GC: ~14 MB Used (Why doesn't this go down to 0-2 again?)
To get the spike solution working, simply create files for the following 3 classes then create a texture image named "image.png" in a package named "j3dheaptester". There are 4 files you need (The driver, the JFrame containing the Canvas3D, an Appearance containing a texture, and a texture image). The class I have been focusing on is TextureAppearance.java since my guess is that I can't get the bytes in my texture back.
Any ideas as to how to get these items GC'd?
Message was edited by: jeeky
I don't see an obvious attachment button, so I'll paste the code.