Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leak #159

Closed
kamilfb opened this issue Jul 3, 2015 · 6 comments
Closed

Possible memory leak #159

kamilfb opened this issue Jul 3, 2015 · 6 comments

Comments

@kamilfb
Copy link

kamilfb commented Jul 3, 2015

Hi! Recently I've noticed that my app is running out of memory. I took a heap dump and saw a lot of references to org.reactfx.* and org.fxmisc.*

Attached is a screenshot from MAT.

In this particular case, the data field was updated about 300 times per second by doing:

dataField.clear();
dataField.appendText(textToDisplay);
dataField.setStyleClass(0, dataField.getText().length(), "messageText");

The dataField is an instance of StyleClassedTextArea. Using 0.6.3.

leak

Any help appreciated!

@TomasMikula
Copy link
Member

Can you test how the heap usage evolves with time and garbage collection? For example

  1. Startup your app, run GC, report heap usage.
  2. Run your loop 1000 times, run GC, report heap usage.
  3. Run your loop another 1000 times, run GC, report heap usage.

If you see a significant increase between 2. and 3., can you please provide a reproducible example?

Thanks.

@kamilfb
Copy link
Author

kamilfb commented Jul 4, 2015

Hi Tomas. I did something a bit different, but hopefully easier for you to look at. I wrote a simple app that recreates the problem. It has 4 tabs, first two with StyleClassedTextArea and the other two with TextArea. The reason for two each is that I was suspecting it was to do with hidden tabs, but that doesn't seem to be the case.

Also attached a screenshot from jconsole, with a summary from 3 runs. On the left - only updating a TextArea tab, max memory usage about 45MB, low CPU usage. The middle and the right ones are updating the StyleClassedTextArea tabs (first and both tabs respectively). You can see the memory usage going to almost 900MB, and with high CPU usage. After a while it doesn't do much processing but runs at high CPU, so I believe it is doing constant GCs (the count keeps increasing every second for majors). Also tried doing manual GCs but not much difference.

The sample app: https://drive.google.com/open?id=0B3K44MOFJ2-PR1lsUTB3amlXem8

test runs

@TomasMikula
Copy link
Member

Thanks,

I found a leak, which is an instance of "Problem 2" from my blog post on The Trouble with Weak Listeners. I will report this specific instance to the JavaFX team.

This leak is very specific to your example, namely, when there are many updates of a paragraph, without moving the caret in and out of that paragraph. Can you confirm that the memory is reclaimed when you move the caret to the next line (and run GC)?

@TomasMikula
Copy link
Member

Here is the issue I reported: https://bugs.openjdk.java.net/browse/JDK-8130458

@TomasMikula
Copy link
Member

So the above mentioned JDK bug has been fixed, but is not released yet and it is unsure whether the fix will be backported to some JDK 8 update release. Therefore, I created a workaround for it in version 0.6.7.

@kamilfb
Copy link
Author

kamilfb commented Sep 9, 2015

Hi Tomas. Many thanks for sorting it out and for the update. I'll go to the latest version. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants