[Python-Dev] Memory Allocator Part 2: Did I get it right?
ejones at uwaterloo.ca
Tue Feb 15 22:39:38 CET 2005
After I finally understood what thread-safety guarantees the Python
memory allocator needs to provide, I went and did some hard thinking
about the code this afternoon. I believe that my modifications provide
the same guarantees that the original version did. I do need to declare
the arenas array to be volatile, and leak the array when resizing it.
Please correct me if I am wrong, but the situation that needs to be
supported is this:
While one thread holds the GIL, any other thread can call PyObject_Free
with a pointer that was returned by the system malloc.
The following situation is *not* supported:
While one thread holds the GIL, another thread calls PyObject_Free with
a pointer that was returned by PyObject_Malloc.
I'm hoping that I got things a little better this time around. I've
submitted my updated patch to the patch tracker. For reference, I've
included links to SourceForge and the previous thread.
More information about the Python-Dev