You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Memory not released upon multiple Initialize/Shutdown #2594
I am on windows 11 (64bit), using PythonNet v3.0.5, combined with Python 3.8 (happens with Python 3.12 as well).
For more context, we have a WebAPI that runs python 3 code that interacts with C# code. I tried avoiding initalization and shutdown systematically, but then I encounter API crashes. While current implementation might not be perfect (especially given 2008 - that we are facing as well, but is not the topic), it works, besides the increasing memory consumption.
Am I missing anything regarding resources freeing?
When run from VS Debugger against Python 3.13.3 official release, we seem to leak 25 objects/1.51 kB per iteration, mostly anonymous types within Python.Runtime.Interop:
They seem to be rooted at the following static variables:
all new objects: Python.Runtime.Interop.allocatedThunks
additionally, the "+5" instances: Python.Runtime.SlotsHolder
At least the allocatedThunks member is add-only, based on the "find all references" result:
Activity
Ledragon commentedon May 28, 2025
Hey,
Any comment on this? Not asking for a solution, but maybe just an insight on knowing if what I am doing is intrinsically wrong?
kunom commentedon Jul 18, 2025
When run from VS Debugger against Python 3.13.3 official release, we seem to leak 25 objects/1.51 kB per iteration, mostly anonymous types within
Python.Runtime.Interop:They seem to be rooted at the following static variables:
Python.Runtime.Interop.allocatedThunksPython.Runtime.SlotsHolderAt least the
allocatedThunksmember is add-only, based on the "find all references" result: