Memory leak in string interop
TorchSharp uses PinnedArray<IntPtr> 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.
@zgxnet -- thank you for noticing this problem. I will take a look at it and see what we can do. You're also welcome to submit a PR with a fix.
It seems that the problem is not fixed.
You are right -- it was linked to a PR that I had first imagined would take care of it, but with numerous process crashes, it turned into a much smaller change. The problem remains.