Thanks for the replay. I run this script as __main__ module, this module is removed from sys.modules, and the ref count becomes 0.
2016-09-20 0:00 GMT+08:00 Chris Angelico <ros...@gmail.com>: > On Mon, Sep 19, 2016 at 4:47 PM, dl l <ldlch...@gmail.com> wrote: > > 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. That > > cause the memory leak. > > Does the module still exist in sys.modules? If so, it's not leaked - > it's still in use. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list