Memoryleaks in JavaFX 2.2 TableView and friends


One of the really bad things in JavaFX 2.2 is that it has some serious memoryleaks in conjunction with TableViews.

I’ve filed a bug report against it (RT-32087) to it is fairly uncertain that there’s ever going to be a fix in 2.2 which is a real problem if you need to go GA before March 2014. So together with one of our customers we’ve studied heap dumps to find out where the strong references have been held so that we could go brute force way using reflection and clearing them up.

Daniel has posted our findings at http://www.modellwerkstatt.org/home/javafxtableviewmemoryleak

I hope this helps others having the same troubles

14 thoughts on “Memoryleaks in JavaFX 2.2 TableView and friends

  1. Craig Day September 20, 2013 / 1:17 am

    Oracle totally dropped the ball on JavaFX2. It is riddled with bugs and memory leaks, code that is nowhere near production-worthy, none of which will get fixed (maybe) until FX8. Can you get it to work, yes, with reflection hacks remarkably similar to yours🙂. We have shipped a large, sophisticated trading platform using it, but if we had known what we were in for, there is a good chance we might have taken another route (maybe Swing even). Lets hope FX8 is better.

    p.s. did you know TableCellSkin instances cost around 7K in memory? 14MB just for the cells in a 20 column 100 row table is insane. The real business data in our app comes to less than 70MB. The other 600MB is JavaFX.

  2. sco0ter September 20, 2013 / 12:15 pm

    Did you try my workaround, which I posted in Jira issue?

    • Tom Schindl September 20, 2013 / 11:17 pm

      Although the problem there is in the same area the leak we fixed with this customer had nothing to do with graphics, I also think the sample I posted does not exhibit ALL memory leaks produced by the *View controls

  3. Wolfgang September 24, 2013 / 8:51 am

    what is your personal experience with FX8? Do you think the memory leak problems were solved? I installed the latest JDK ( build b108) and was surprised by the enormous initial memory consumption in the demo applications that rapidly grew when navigating back and forth in the UI a couple of times.

    • Tom Schindl September 24, 2013 / 9:01 am

      In the scenario we have FX8 fixed the problems. Generally speaking FX8 performs a lot better than FX2 and many problems have been fixed. Which demo app are you running? Might be worth to analyze it and see if there are other leaks. I’m sure when we bring them to the attention of the FX-Team we can get them fixed before FX8 goes GA, I’m always wondering – like with our problem – if this should be part of the SQE of such a library.

      • javahacks September 24, 2013 / 2:26 pm

        I just had a look at the Modena and Ensemble applications provided in the javafx samples. The memory usage was more than 1 GB after a few clicks. Too much for a simple UI demonstration.

      • Tom Schindl September 24, 2013 / 2:30 pm

        Agreed! It would be interesting to see where the memory is going to. If i have time i give MAT a spin on them

  4. bimboxX November 8, 2013 / 1:40 am

    Hi Tom, can you expound more on why we have to remove the actions and listeners (3), and also clear the columns (4)?

    • Tom Schindl November 8, 2013 / 12:25 pm

      Those are just to make extra sure nothing is referenced even if it is a weak reference internally, on of the problems of inner-classes is that they hold a strong ref to the outer class, which means that the inner-class is only released once the outer class is gc’ed

      • bimboxX November 11, 2013 / 8:26 am

        Thanks for explaining. It would be great if you or Daniel could have another blog post explaining the reasons for the workarounds in detail.

  5. Neo March 28, 2014 / 9:46 am

    Hi Tom,

    I am stuck in the same issue. I had a look on your code but the problem is that i dont have reference of selection listener in my code. So can u pls modify the code to remove all selection listeners and callbacks using reflection.

    Thanks,
    Neo

    • Tom Schindl March 28, 2014 / 3:44 pm

      I’m sorry but I’m not fixing your problems for free.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s