Welcome to yEd Q&A!
Here you can ask questions and receive answers from other members of the community and yEd developers. And you can tell us your most wanted feature requests.

Categories

Memory Leak in OrgChartDemo JavaFX when repeated add/clear

0 votes
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();

    }

  }
closed with the note: Not a yEd question.
in Help by
closed by

1 Answer

0 votes

This forum is for yEd questions only. For questions regarding the yFiles for JavaFX programming library, please contact yWorks support by mail. (Please include your yWorks customer or evaluator ID in your mail when doing so.)

by [yWorks] (160k points)
Legal Disclosure | Privacy Policy
...