mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
gh-112075: Support freeing object memory via QSBR (#116344)
Free objects with qsbr if shared
This commit is contained in:
parent
61831585b6
commit
7db871e4fa
4 changed files with 68 additions and 13 deletions
|
@ -1695,6 +1695,7 @@ PyObject_GC_Del(void *op)
|
|||
{
|
||||
size_t presize = _PyType_PreHeaderSize(((PyObject *)op)->ob_type);
|
||||
if (_PyObject_GC_IS_TRACKED(op)) {
|
||||
_PyObject_GC_UNTRACK(op);
|
||||
#ifdef Py_DEBUG
|
||||
PyObject *exc = PyErr_GetRaisedException();
|
||||
if (PyErr_WarnExplicitFormat(PyExc_ResourceWarning, "gc", 0,
|
||||
|
@ -1707,8 +1708,13 @@ PyObject_GC_Del(void *op)
|
|||
}
|
||||
|
||||
record_deallocation(_PyThreadState_GET());
|
||||
|
||||
PyObject_Free(((char *)op)-presize);
|
||||
PyObject *self = (PyObject *)op;
|
||||
if (_PyObject_GC_IS_SHARED_INLINE(self)) {
|
||||
_PyObject_FreeDelayed(((char *)op)-presize);
|
||||
}
|
||||
else {
|
||||
PyObject_Free(((char *)op)-presize);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue