[JAVA3D-INTEREST] ImageComponent2DRetained Memory Usage
I am working with an application that needs to create and use many Textures
during runtime, which continually get added and removed from the scenegraph.
For each texture there is an ImageComponent2D, and therefore an
ImageComponent2DRetained (although there are many of these, about 3:1, for
each image component, but that is another issue).
After a while, I found that my application consumes all available memory.
Running it through the profiler I found that the ImageComponent2DRetaineds
are getting stuck in the Finalizer list waiting for finalization. Looking at
the code, it is true that ImageComponent2DRetained does indeed have a
finalize method used to release the D3D texture. Due to the high cost of
allocation and GC with finalizers
(http://www-106.ibm.com/developerworks/library/j-jtp01274.html) is there a
better way to allow the ImageComponent2DRetained to release its texture?
What happens if the finalizer is never called (as could be the case
according to the java spec)?
The major problem is that each ImageComponent2DRetained maintains its
reference to the original texture image (which is 256 x 256 x 4 in my case)
while in the finalizer list of the GC, causing quite a memory problem. There
does not appear to be a way to force the ImageComponent2DRetained to release
its reference to the image data while waiting for finalization. Also, object
pooling of the ImageComponent2D objects does not help since setting a new
image on it appears to force the creation of another
ImageComponent2DRetained. Due to the possible short lifespan of an
ImageComponent2DRetained, a finalizer does not seem appropriate.
Although I am not completely familiar with the finalizer thread, I found
that increasing the thread priority of the allocating thread helped to force
finalization on the pending objects, however this is not a preferred
Does anyone have a suggestion, or a comment on what can be done about the
use of finalizers in ImageComponent2DRetained (and possibly elsewhere in
To unsubscribe, e-mail: firstname.lastname@example.org
For additional commands, e-mail: email@example.com