I have a memory leak in my test app. I'm not sure I remove the objects the right way because the profiler shoes they do not get destroyed. My test is based on OrgChartDemo so I did the following to confirm (to your demo app)
I added a timer to re - add the contents every 5 seconds.
Call graph.clear() before adding it again.
Get Memory leak.
Added this to the end of the initialse function in OrgChartDemo.java:
Timeline timeline = new Timeline(new KeyFrame(
javafx.util.Duration.millis(5000),
ae -> buildSampleGraph()));
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
private void buildSampleGraph() {
try {
URL url = OrgChartDemo.class.getResource("resources/samplegraph.graphml");
// create an IOHandler that will be used for all IO operations
final GraphMLIOHandler ioh = new GraphMLIOHandler();
// we set the IO handler on the GraphControl, so the GraphControl's IO methods
// will pick up our handler for use during serialization and deserialization.
//-------> add this to clear old data:
graphControl.getGraph().clear();
graphControl.setGraphMLIOHandler(ioh);
ioh.addXamlNamespaceMapping("
http://www.yworks.com/yfiles-for-javafx/demos/OrgChartEditor/1.0", Employee.class);
graphControl.importFromGraphML(url);
} catch (IOException e) {
e.printStackTrace(System.err);
} catch(Exception e){
e.printStackTrace();
}
}