- Notifications
You must be signed in to change notification settings - Fork750
Closed
Description
Environment
- Pythonnet version: 2.3.0
- Python version: 3.6.1
- Operating System: Windows 7 Professional 64bits.
- .NET Framework 4.6
Details
- I experience memory leaks when trying to use a C# dll in python to run a simulation and retrieve results using python. When I try to run multiple time the calculation I get leaks
Here is a template of code I run to experience this memory leak (replaced the name of the dll I use by generic names)
importclrimportosimportsysimportpsutilimportgcdll_path=r''thepathtomydll"sys.path.append(os.path.join(dll_path,'MyDll.dll'))clr.AddReference(os.path.join(dll_path,"MyDll"))whilepsutil.virtual_memory().percent<80:print('psutil_virtual_memory:',psutil.virtual_memory().percent)obj=MyDll.MyObject()res=obj.Run()# long simulation is run and I get the results.gc.collect()clr.System.GC.Collect()
Output :
psutil_virtual_memory: 41.8
psutil_virtual_memory: 44.4
psutil_virtual_memory: 46.6
psutil_virtual_memory: 48.9
.....
until my memory reach 80%
The issue is that running the equivalent code in C# does not give any memory leak but it's when calling it from python we get issues of memory leaks. the python garbage collector doesn't help at all with this. I tried also to call the System GC Collect but without success too.
My question is how can I investigate and try to fix this issue.
Metadata
Metadata
Assignees
Labels
No labels