Skip to main content

Memory and Threads

1 reply [Last post]
mdomin
Offline
Joined: 2007-08-16
Points: 0

Hi there!

I have a Java3d application for loading and visualizing rather large data sets. I've noticed a quite severe increase in heap memory which is not garbage collected properly.

After each unloading of my data I'm in fact destroying every object connected with Java3d by dereferencing them, even Canvas3D. So I'm able to initialize and reset everything to a certain state when loading another data set.

I used JConsole (and Netbeans profiler) to track down the possible problem for the using up of the heap when I recognized, that after each loading of a new data set, in the moment of initialization of the Canvas3D and the several Branchgroups, a whole new set of Java3d threads came to live. After each unloading and loading and setting up the Canvas3D, nine new Threads were started. All of them remained alive, so after a while I have a lot of threads which aren't in use anymore (apart from the newest ones), but still were kept in memory, perhaps being responsible for the increasing memory footprint. I wasn't able to find out which resources were used or held by these old threads…

Here the list of the threads that are started multiple times:

J3D-BehaviorStructureUpdateThread

J3D-GeometryStructureUpdateThread
J3D-SoundStructureUpdateThread
J3D-RenderingEnvironmentStructureUpdateThread
J3D-TransformStructureUpdateThread
J3D-BehaviorScheduler
J3D-RenderStructureUpdateThread
J3D-SoundSchedulerUpdateThread
J3D-InputDeviceScheduler
Is it normal to have all of these threads from <thread_name>-1 to -22 or beyond? And is it a good approach to destroy all Java3d objects for being able to initialize the application to a certain state?
Help would be very much appreciated!
Martin

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mdomin
Offline
Joined: 2007-08-16
Points: 0

Found my own solution!

Obviously it is a bad idea to destroy a Canvas3D and reinstantiate it multiple times during the life time of an application.

I solved it by resetting the Branchgroups, Transformgroups, Transforms etc. without destroying (most of) the respective objects. Seems, I'm doing it correctly now, even after many reload cycles the used heap memory remains on a stable level.