You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@opennlp.apache.org by "Kristian Rickert (Jira)" <ji...@apache.org> on 2026/06/12 04:41:00 UTC
[jira] [Created] (OPENNLP-1840) NameFinderDL leaks native ONNX resources on every find() call
Kristian Rickert created OPENNLP-1840:
-----------------------------------------
Summary: NameFinderDL leaks native ONNX resources on every find() call
Key: OPENNLP-1840
URL: https://issues.apache.org/jira/browse/OPENNLP-1840
Project: OpenNLP
Issue Type: Bug
Components: dl, Name Finder
Reporter: Kristian Rickert
Assignee: Kristian Rickert
{{NameFinderDL.find()}} creates up to three {{OnnxTensor}} inputs ({{input_ids}}, {{attention_mask}}, {{token_type_ids}}) and an {{OrtSession.Result}} per sentence chunk, but never closes them. Each call therefore accumulates off-heap native memory that is only reclaimed when the process exits -- the same defect fixed for {{SentenceVectorsDL}} in OPENNLP-1836 and {{DocumentCategorizerDL}} in OPENNLP-1839.
Long-running services invoking {{find()}} repeatedly will grow native memory unbounded until the process is OOM-killed, while the Java heap looks healthy.
The fix is the established pattern: close the input tensors in a {{finally}} block and the {{OrtSession.Result}} via try-with-resources ({{getValue()}} copies into Java arrays first, so closing is safe).
{{NameFinderDL.tokenize()}} also has the same auto-unboxing {{NullPointerException}} on vocabulary misses ({{vocab.get(tokens[x])}} into {{int}}) that OPENNLP-1839 fixed for {{DocumentCategorizerDL}}; it should throw a descriptive {{IllegalArgumentException}} instead.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)