Re: Python C API: How to debug reference leak?

2016-09-27 Thread dl l
When I debug in C++, I see the reference count of a PyObject is 1. I don't know where is referencing this object. How can I find out where is referencing this object? 2016-09-27 15:47 GMT+08:00 dl l : > Thanks for reply. Is there any function in C to get the reference objects > of

Re: PyImport_AddModule vs PyImport_Import

2016-09-27 Thread dl l
Thanks. That's helpful. I did not notice the note. 2016-09-27 19:24 GMT+08:00 Ned Batchelder : > On Tuesday, September 27, 2016 at 3:54:01 AM UTC-4, dl l wrote: > > What is the difference between PyImport_AddModule and PyImport_Import? > > > > When need to use PyImpo

PyImport_AddModule vs PyImport_Import

2016-09-27 Thread dl l
What is the difference between PyImport_AddModule and PyImport_Import? When need to use PyImport_AddModule? When need to use PyImport_Import? -- https://mail.python.org/mailman/listinfo/python-list

Re: Python C API: How to debug reference leak?

2016-09-27 Thread dl l
Thanks for reply. Is there any function in C to get the reference objects of a object? I want to debug where are referencing the object. 2016-09-27 15:01 GMT+08:00 dieter : > dl l writes: > > I want to check the references of an object. Any way to get the > references > >

Python C API: How to debug reference leak?

2016-09-26 Thread dl l
I want to check the references of an object. Any way to get the references of an object with Python C API? Like: gc.get_referrs(), is there similar API in C lib? -- https://mail.python.org/mailman/listinfo/python-list

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

2016-09-20 Thread dl l
= 2016-09-21 13:09 GMT+08:00 dieter : > dl l writes: > > I found the problem is resolved if call PyGC_Collect() after > > PyDict_DelItemString(). Is it expected to call PyGC_Collect() here for > > Python 3.5 which is not needed for Python 3.3? > > Usually, Python use

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

2016-09-20 Thread dl l
Thank you all for the help. I found the problem is resolved if call PyGC_Collect() after PyDict_DelItemString(). Is it expected to call PyGC_Collect() here for Python 3.5 which is not needed for Python 3.3? 2016-09-20 16:01 GMT+08:00 Chris Angelico : > On Tue, Sep 20, 2016 at 4:19 PM, d

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

2016-09-19 Thread dl l
equires my customers to update their python scripts. That may make them unhappy :(. Is there a workaround in my code C++ side to call Python C APIs to resolve the memory leak issue? 2016-09-20 13:49 GMT+08:00 Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info>: > On Monday 19 Septembe

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

2016-09-19 Thread dl l
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 : > On Mon, Sep 19, 2016 at 4:47 PM, dl l wrote: > > I have a app loading python35.dll. Use python API PyImport_

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

2016-09-19 Thread dl l
Hi, 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 memor