Python C API: How to debug reference leak?

dl l ldlchina at gmail.com
Tue Sep 27 21:28:45 EDT 2016


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

> 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 <dieter at handshake.de>:
>
>> dl l <ldlchina at gmail.com> writes:
>> > 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?
>>
>> "gc" is a module. You can import and access modules from the C API.
>> Thus, you can use "gc.get_referers" from "C" code.
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>



More information about the Python-list mailing list