onnxruntime
5ae3496c - Release outputHandlesArr in OrtTrainingSession.evalStep JNI binding (#29576)

Commit
13 days ago
Release outputHandlesArr in OrtTrainingSession.evalStep JNI binding (#29576) ### Description `Java_ai_onnxruntime_OrtTrainingSession_evalStep` acquires the output handle array with `GetLongArrayElements(jniEnv, outputHandlesArr, NULL)` but never calls the matching `ReleaseLongArrayElements`, so the pinned array (or its native copy, depending on the JVM) leaks on every call and on all return paths: the `EvalStep` error `goto`, the output-conversion failure, and the normal success return. This adds the release with `JNI_ABORT` immediately after the handle pointers are copied into `outputValues`, before `EvalStep` is invoked, so it covers every subsequent path. `JNI_ABORT` is correct because the handles are only read. The change mirrors the input handling a few lines above in the same function, and the sibling `trainStep()` and `OrtSession.run()` bindings, which already release their output handles this way. Inference results are unaffected, which is why functional tests do not catch the leak. ### Motivation and Context Fixes #29573. `evalStep()` was the only one of the three equivalent bindings missing the release, so repeated evaluation (for example a validation loop) accumulated native memory and GC pressure.
Author
Parents
Loading