* Fix calculation of PyListObject size in allocator
* Fix size calculation in _PyDict_DebugMallocStats
* Fix memory size calculation in tupleobject.c
Adjusted memory calculation for PyTupleObject freelist entries.
* Revert in tupleobject.c
Removed unnecessary comment regarding memory calculation and the memory calculation itself.
* 📜🤖 Added by blurb_it.
* Update tupleobject.c
---------
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
--- /dev/null
+Repaired undercount of bytes in type-specific free lists reported by sys._debugmallocstats(). For types that participate in cyclic garbage collection, it was missing two pointers used by GC.
{
_PyDebugAllocatorStats(out, "free PyDictObject",
_Py_FREELIST_SIZE(dicts),
- sizeof(PyDictObject));
+ _PyType_PreHeaderSize(&PyDict_Type) + sizeof(PyDictObject));
_PyDebugAllocatorStats(out, "free PyDictKeysObject",
_Py_FREELIST_SIZE(dictkeys),
sizeof(PyDictKeysObject));
_PyDebugAllocatorStats(out,
"free PyListObject",
_Py_FREELIST_SIZE(lists),
- sizeof(PyListObject));
+ _PyType_PreHeaderSize(&PyList_Type) + sizeof(PyListObject));
}
PyObject *
PyOS_snprintf(buf, sizeof(buf),
"free %d-sized PyTupleObject", len);
_PyDebugAllocatorStats(out, buf, _Py_FREELIST_SIZE(tuples[i]),
- _PyObject_VAR_SIZE(&PyTuple_Type, len));
+ _PyType_PreHeaderSize(&PyTuple_Type) + _PyObject_VAR_SIZE(&PyTuple_Type, len));
}
}