diff --git a/CHANGELOG.md b/CHANGELOG.md index 125e8ca5b2f..4cfda86aba0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We made the command "Push to TexShop" more robust to allow cite commands with a character before the first slash. [forum#2699](https://discourse.jabref.org/t/push-to-texshop-mac/2699/17?u=siedlerchr) - We only show the notification "Saving library..." if the library contains more than 2000 entries. [#9803](https://github.com/JabRef/jabref/issues/9803) - We enhanced the dialog for adding new fields in the content selector with a selection box containing a list of standard fields. [#10912](https://github.com/JabRef/jabref/pull/10912) +- We store the citation relations in an LRU cache to avoid bloating the memory and out-of-memory exceptions. [#10958](https://github.com/JabRef/jabref/issues/10958) - Keywords filed are now displayed as tags. [#10910](https://github.com/JabRef/jabref/pull/10910) ### Fixed diff --git a/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/BibEntryRelationsCache.java b/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/BibEntryRelationsCache.java index 3f2f9f53b7b..55888aa660f 100644 --- a/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/BibEntryRelationsCache.java +++ b/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/BibEntryRelationsCache.java @@ -1,16 +1,18 @@ package org.jabref.gui.entryeditor.citationrelationtab; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.identifier.DOI; +import org.eclipse.jgit.util.LRUMap; + public class BibEntryRelationsCache { - private static final Map> CITATIONS_MAP = new HashMap<>(); - private static final Map> REFERENCES_MAP = new HashMap<>(); + private static final Integer MAX_CACHED_ENTRIES = 100; + private static final Map> CITATIONS_MAP = new LRUMap<>(MAX_CACHED_ENTRIES, MAX_CACHED_ENTRIES); + private static final Map> REFERENCES_MAP = new LRUMap<>(MAX_CACHED_ENTRIES, MAX_CACHED_ENTRIES); public List getCitations(BibEntry entry) { return CITATIONS_MAP.getOrDefault(entry.getDOI().map(DOI::getDOI).orElse(""), Collections.emptyList());