Bug 538088 - Possible memory leak in ClickDragGesture
Summary: Possible memory leak in ClickDragGesture
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF MVC (show other bugs)
Version: 5.0.100   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard: low-hanging fruit
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-20 08:37 EDT by Markus Muehlbrandt CLA
Modified: 2018-10-17 08:20 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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().