dotnet / dotnet/TorchSharp

Memory leak in string interop

Open
#966 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.9k
Forks
228
PR merge metrics
No merged PRs in 30d

Description

TorchSharp uses PinnedArray for string interop, and it does not release the handles explicitly and wishes PinnedArray to release the IntPtr handles when disposing. However, PinnedArray auto-release needs IDisposable to work with, which IntPtr does not implement. I suggest using a dedicated PinnedPtrArray, which is able to release all the handles properly.

Contributor guide

Open the contributing guide

Research direction

Start by tracing TorchSharp's string interop use of PinnedArray and the proposed PinnedPtrArray. No file or test is named, so locate those types and inspect their disposal behavior first. Done means the interop handles are released when the array is disposed and the relevant tests pass; note that linked pull request 968 was merged.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.