Python 3.5.1, the global variable is not destroyed when delete the module
<p>I have a app loading python35.dll. Use python API PyImport_AddModule to run a py file. And use PyDict_DelItemString to delete the module. There is a global vailable in the py file. The global variable is not destroyed when calling PyDict_DelItemString to delete the module. The global variable is destroyed when calling Py_Finalize. It's too late. That cause the memory leak. Because the Py_Initialize is called at the app startup, the Py_Finalize is called at the app shutdown. </p>

<p>But it is ok with python33.dll, the global variable can be destroyed when calling PyDict_DelItemString to delete the module.</p>

<p>How to resolve the problem? Is there a workaround? I need to use python35.dll and wish the global variable in a module can be released automatically when call PyDict_DelItemString to delete the module.</p>

<p>Here is the python test code:</p>

<pre><code>class Simple:  
     def __init__( self ):  
         print('Simple__init__')
     def __del__( self ):  
         print('Simple__del__') 

simple = Simple()
</code></pre>

<p>This problem is resolved. Need to call PyGC_Collect after PyDict_DelItemString with Python post 3.4 versions.</p>

<p>For detailed info, please read <a href="http://bugs.python.org/issue28202" rel="nofollow">http://bugs.python.org/issue28202</a>.</p>

python python-3.x pyobject