mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-24 05:18:58 +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
5766da69ec
commit
7f7021ce64
@ -60,15 +60,18 @@ public class SentenceExtractor {
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
if (ngramLexicon == null) {
|
||||
ngramLexicon = new NgramLexicon(models);
|
||||
}
|
||||
|
||||
if (rdrposTagger == null) {
|
||||
try {
|
||||
rdrposTagger = new RDRPOSTagger(models.posDict, models.posRules);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user