mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-24 13:19:02 +00:00
(sentence-extractor) Fix resource leak in sentence extractor
The code would always re-initialize the static ngramLexicon and rdrposTagger fields with new instances even if they were already instantiated, leading to a ton of unnecessary RAM allocation. The modified behavior checks for nullity before creating a new instance.
This commit is contained in:
parent
e3316a3672
commit
adc90c8f1e
@ -60,15 +60,18 @@ public class SentenceExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
if (ngramLexicon == null) {
|
||||||
ngramLexicon = new NgramLexicon(models);
|
ngramLexicon = new NgramLexicon(models);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rdrposTagger == null) {
|
||||||
try {
|
try {
|
||||||
rdrposTagger = new RDRPOSTagger(models.posDict, models.posRules);
|
rdrposTagger = new RDRPOSTagger(models.posDict, models.posRules);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
throw new IllegalStateException(ex);
|
throw new IllegalStateException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user