Memory leak in string interop

Open
#966 4 comments 0 reactions 0 assignees View on GitHub

A pull request for this has already been merged.

  • #968 by @NiklasGustafsson — merged

Assessment

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

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.

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.

Dominant language
C#
Stars
1.9k
Forks
228
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/TorchSharp

All issues in dotnet/TorchSharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.