[CXX API] Fix memory leak for KernelContext_GetAllocator by adrianlizarraga · Pull Request #26883 · microsoft/onnxruntime

@adrianlizarraga

skottmckay

alex-spacemit pushed a commit to spacemit-com/onnxruntime that referenced this pull request

Jan 20, 2026
…6883)

### Description
- Updates the C++ API function `Ort::KernelContext::GetAllocator` to
return a `Ort::Allocator`, which releases the allocator instance on
destruction.
- Fixes a memory leak in a unit test by using the fixed
`Ort::KernelContext::GetAllocator` API.



### Motivation and Context
Users of the C++ API should not have to manually call `ReleaseAllocator`
on the result of `Ort::KernelContext::GetAllocator`. This expectation
will make leaking memory common.

Refer to original PR that added the API:
microsoft#15591