-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
JabRef should release unused heap more frequently #3113
Comments
@tobiasdiez I suspect that bindings are the cause of this all. I know your time is limited, but can you please have a look at this? It's really a game changer... |
Confirmed. Had about 2.5GB allocated RAM after 5 minutes of clicking around in a Bibtex File with about 50 entries. Closing the EntryEditor did not help:/ JabRef 4.0-beta3 |
The main reason for the memory leak is that the event listener in the source tab is never unregistered: https://github.com/JabRef/jabref/blob/master/src/main/java/org/jabref/gui/entryeditor/SourceTab.java#L55 After uncommenting this line, the memory still increases a bit for each new entry but not as much as before. I tried to further investigate the issue but couldn't really pinpoint the cause. First of all, mostly int arrays are left over after opening a bunch of entries (the screenshot shows the difference in the memory consummation/allocated objects between a clean start and after the entry editor was opened for a few entries): However, most of these arrays are actually no longer referenced and can be removed by garbage collection (no idea, why these are kept): It appears that these numbers (and the other objects like HashMaps) have their origin in JavaFX. The bigger int arrays are a kind of raster image of older entry editors. Moreover, a few other objects are referenced by a cache in the JavaFX style manager (but again, these are weak hash maps). Sorry, I don't have time to have closer look or even provide a fix. But I can definitely recommend the YourKit Java Profiler (see e.g. their documentation about memory leaks; license is in admin rep) |
@tobiasdiez Thanks for looking into this! I can confirm that the source pane is the most critical. Oh boy, I am happy that this was due to my changes, because it means that it's easy to repair. #3116 repairs the event deregistration in the source tab. I would suggest the following: When #3116 is merged, the obvious blocker is gone and we can remove this issue from the 4.0 milestone. But we should keep investigated why the heap size doesn't really go down. After all, most of the heap reserved for JabRef is actually unused. |
I wonder if we could add some regression test that does the memory profiling automatically for us. Like selenium, just for java apps. |
Since the PR is merged, I've renamed this issue. Our main problem is not that JabRef consumes too much memory, but that it doesn't release unused heap. If there's a peak consumption, then JabRef somehow doesn't give memory back to the operating system when it's no longer needed. EDIT: And since the memory leak is fixed, we can remove this from the 4.0 milestone. |
I can confirm this issue with the 4.0-dev version. After using JabRef for a while, memory consumption goes up from 5.8% (start) to 18.1% and more. That's when I close and reopen it. |
To take some information from the PR linked above, the typical memory usage look like in this picture: Sometimes there is a peak in memory usage (i.e. cycling through the entry editor) which makes Java reserve a lot of memory. When garbage collection happens, the used heap goes down a lot. For some reason, Java does not release the unused heap again. If we manage to make the VM do this, then the memory problem would be solved. Unfortunately, I don't know how to do this. |
I tried to limit memory consumption by adding |
@j0hannes Did you pass the arguments to the jar file? |
@Siedlerchr, I changed my #!/bin/sh
# Force usage of latest java version
JVM_PATH=$(find /usr/lib/jvm/* -maxdepth 0 -type d | sort | tail -n1)
exec $JVM_PATH/jre/bin/java -Xmx750M -jar /usr/share/java/jabref/JabRef.jar "$@" |
Seems that this is no solution to the problem. The entry editor is broken after a while (won't display entries completely) and memory consumption readily exceeds the given limit. |
Is there a way for JabRef to detect when memory consumption is running riot and restart itself? |
Well, we know what triggers the peaks. It is when you cycle through the main table with up/down keys when the entry editor is open or when you click around in the main table really fast. Every selection change in the main table will trigger the creation of a new entry editor and this is what's consuming memory. I'm not sure that restarting JabRef would be good from a usability point of view, though. I think the long term solution is to not create entry editors all the time, but rather to update the parts that should change. Unfortunately, that is really quite a big refactoring. The start is here #3187 but it is still quite a long way to go. |
For now, an automatic restart or a restart button would be very helpful. If I've used JabRef a lot (many entries opened in entry editor) and forget to close it before compiling it will crash my system due to insufficient memory. I could somehow replace the compile commands with scripts that close JabRef on compiling a document and restart it afterwards but that wouldn't be hassle-free neither. |
@j0hannes There have been some significant performance improvements during the last days. You might want to update to the most recent development version, which could already help your workflow. On top of that, more performance improvements are already in the pipeline. |
With the merge of #3333, we have driven down the memory consumption in the entry editor significantly. With the new memory profile, GC tends to kick much sooner and more often than previously (at least on some systems). Hence, this issue can be closed. In case of new performance problems, we can open a new issue. |
@lenhard The new version runs smoothly on Linux. I've even seen the process giving back memory to the system. On OS X, I don't see memory issues with the new version either. It tends to freeze frequently, but that's probably a different story. |
That is great to hear. Thank you very much for reporting! |
This issue also appears in the release version. When JabRef 4.0 starts its allocated memory is 363MB and keeps climbing all the time. After 30-40min JabRef becomes so slow that it results necessary to force closing it. |
@javicacien Yes, of course the problem is present in 4.0. That is exactly what this issue was about. The problems described are fixed in the current dev version, which is not yet released. That version is available at http://builds.jabref.org/master/ |
Sorry, I misunderstood the posts, I was thinking that they were referring to the "dev" version prior to 4.0 |
The memory problem is still not solved in JabRef 4.2 )Windows 7 6.1 amd64, Java 1.8.0_161) |
Currently my JabRef is using 2.5GB of RAM for a library with less than 50 entries. I only installed and started using JabRef yesterday and today started wondering why my PC became slow (8GB of RAM only currently), and noticed JabRef was using this much. JabRef 4.3.1 |
Please use the development version available at http://builds.jabref.org/master/ |
It seems that we have a memory leak with the entry editor on current master, latest commit 0326d77
JabRef 4.0-dev
Windows 7 6.1 amd64
Java 1.8.0_121
To reproduce:
@JabRef/developers Please see if you can reproduce this on your system. This seems quite serious to me and a blocker for 4.0.
Any hints where this might come from are very much appreciated. @koppor Could you maybe try tracking this down with git bisect?
The text was updated successfully, but these errors were encountered: