[SciPy-dev] Real culprit of previous memory problems with array scalars
oliphant.travis at ieee.org
Mon Nov 28 20:07:41 CST 2005
For those that don't follow the python-dev list, here is a summary of
the real problem with the array scalars that was causing the Python
memory manager to eat up memory.
The problem was in the array scalars that dual-inherited from both a
Python type and the generic, base type. Even though the generic,
base-type was listed first, PyType_Ready filled the tp_free function
with the Python Integer free function: int_free (which never released
the previously allocated memory). It worked correctly when the generic
base type tp_free pointer was changed to "free" but curiously not when
it was "PyObject_Del"
Thus, changing the memory allocator really just changed how the pointer
table got filled in from inheritance. Therefore, the Python memory
allocator is not at fault. It might be useful to go back to it as it
allocates pools of memory at a time (which might make array scalar
allocation faster). We just have to make sure the correct tp_free is
obtained on inheritance (we can easily over-ride what PyType_Ready does
and force tp_free to be whatever is wanted).
More information about the Scipy-dev