Bug 538088

Summary: Possible memory leak in ClickDragGesture
Product: [Tools] GEF Reporter: Markus Muehlbrandt <markus.muehlbrandt>
Component: GEF MVCAssignee: gef-inbox <gef-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: matthias.wienand
Version: 5.0.100   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard: low-hanging fruit

Description Markus Muehlbrandt CLA 2018-08-20 08:37:49 EDT
The ClickDrackGesture class contains a private field 'scenes' of type Set<Scene> which is never cleared on deactivation or dispose. As a result the memory bound by the scene nodes is not released. 

Additonally, the weak references in AdaptableScope class field 'scopedInstances' could not removed by the garbage collector in this case.

If you overwrite ClickDragGesture::doDeactivate() function in a subclass and access and clear the 'scenes' set by reflection, the memory is released.
Comment 1 Matthias Wienand CLA 2018-10-17 08:20:16 EDT
Additional insights:

 - JavaFX Scene maintains dirtyNodes that are not cleared when a GEF application is closed inside Eclipse.
 - As a workaround, you could use reflection to clear that array. However, it should be possible to clear it by use of other means, e.g. potentially by setting a new scene root, a new scene, or calling some method that triggers JavaFX clean up, e.g. possibly snapshot().