Community
Participate
Working Groups
When the whole platform is shutdown there are still a few active Threads that prevent the base Eclipse Classloader from unloading. The threads I'm referring to are: 1) the optional "State Data Manager" thread in org.eclipse.osgi.framework.adaptor.core.StateManager 2) the EventThread(s) created by the org.eclipse.osgi.framework.eventmgr.EventManager In both cases the threads are "setDaemon" so they don't prevent the VM from shutting down, however once the platform is shutdown they do not need to be active and as I mentioned prevent GC from happening. -- The "State Data Manager" doesn't currently have a means to shutdown so a patch should add this. The "EventManager" threads do have a shutdown mechanism, it's just a matter of using it. The easiest way I can think of doing this is by holding on to the org.eclipse.osgi.framework.internal.core.OSGi reference in EclipseStarter.startup(...) and calling close() on it during EclipseStarter.shutdown(). I can submit a basic patch to show what I'm thinking about.
Created attachment 28314 [details] Patch to shutdown the daemon threads
Good points. To make sure I understand the problem. You want to GC after the framework has shutdown and free up all the objects used by the framework implementation, right? The threads mentioned in the bug report are framework threads and should only be using classes loaded from the framework implementation. So GC should be possible for objects loaded from other "normal" bundles. But as mentioned in this bug report the deamon threads are staying active and will prevent objects from the framework implementation from GC'ing. We should investigate closing these threads. - StateSaver#shutdown method should stop the "State Data Manager" thread. - EclispeStarter should keep a reference to the OSGi object to close when it is done with the framework (similar to what the attached patch does).
(In reply to comment #2) > You want to GC after the framework has shutdown and free up all the objects used by the framework implementation, right? Correct. These threads aren't the only thing preventing GC but they're a step in that direction. Note: If you _really_ want to see full GC of the platform happen you'll also need the patches from bug#107909.
[contributed patch applied] - I releases a slightly modified version of the patch to stop the "State Data Manager" thread. - I have not released the patch to stop the threads created by the EventManager yet. I have ongoing work in bug 109893 which fixes this issue. If bug 109893 is not fixed for M4 then I will release a fix for the EventManager threads separately. Leaving this bug open until this is resolved.
I released the necessary fixes from bug 109893 to org.eclipse.osgi. This bug should be fixed now.
adding "contributed" keyword to patches contributed by the community.