Battle of the garbage collectors, or ARGGHHHHHH!!!!

Terry Reedy tjreedy at udel.edu
Mon Apr 24 18:59:32 EDT 2017


On 4/24/2017 6:24 PM, CFK wrote:
> TLDR version: the bdwgc garbage collector (http://www.hboehm.info/gc/) and
> python's collector are not playing nice with one another, and I need to
> make them work with each other.
> 
> Long version: I'm trying to write bindings for python via ctypes to control
> a library written in C that uses the bdwgc garbage collector (
> http://www.hboehm.info/gc/).  The bindings mostly work, except for when
> either bdwgc or python's garbage collector decide to get into an argument
> over what is garbage and what isn't, in which case I get a segfault because
> one or the other collector has already reaped the memory.  I need the two
> sides to play nice with one another.  I can think of two solutions:
> 
> First, I can replace Python's garbage collector via the functions described
> at https://docs.python.org/3/c-api/memory.html#customize-memory-allocators
> so that they use the bdwgc functions instead.  However, this leads me to a
> whole series of questions:
> 
>     1. Has anyone done anything like this before?

I know that experiments have been done.
Have you tried searching 'Python bdwgc garbage collection' or similar?

-- 
Terry Jan Reedy




More information about the Python-list mailing list