Tracking a memory leak in C extension - interpreting the output of PYTHONMALLOCSTATS
stefan_ml at behnel.de
Sat Jul 28 15:53:57 EDT 2018
Bartosz Golaszewski schrieb am 24.07.2018 um 13:05:
> Ok I've found the problem and it's my fault. From tp_dealloc's documentation:
> The destructor function should free all references which the instance
> owns, free all memory buffers owned by the instance (using the freeing
> function corresponding to the allocation function used to allocate the
> buffer), and finally (as its last action) call the type’s tp_free
> I'm not calling the tp_free function...
If you want to avoid the little traps of the C-API in the future, give
Cython a try. It can generate all the glue code safely for you, and
probably also generates faster wrapper code than you would write yourself.
More information about the Python-list