From fc28bbf57b8cd2bede6fc06c4ac274fdcd1d7335 Mon Sep 17 00:00:00 2001 From: Sebastian Balzer Date: Mon, 4 Mar 2024 17:50:45 +0100 Subject: [PATCH 1/2] Store Citation Relations in LRU cache --- .../citationrelationtab/BibEntryRelationsCache.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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()); From de1bac8a87f7586020092460635d6eb9146ebbcf Mon Sep 17 00:00:00 2001 From: Sebastian Balzer Date: Mon, 4 Mar 2024 17:54:12 +0100 Subject: [PATCH 2/2] Add changes to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 172492abf17..076fae40eea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,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) ### Fixed