Python 3.5.1 C API, the global available available is not destroyed when delete the module

dl l ldlchina at gmail.com
Mon Sep 19 22:58:54 EDT 2016


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 <rosuav at gmail.com>:

> On Mon, Sep 19, 2016 at 4:47 PM, dl l <ldlchina at 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
>



More information about the Python-list mailing list