mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-113055: Use pointer for interp->obmalloc state (gh-113412)
For interpreters that share state with the main interpreter, this points to the same static memory structure. For interpreters with their own obmalloc state, it is heap allocated. Add free_obmalloc_arenas() which will free the obmalloc arenas and radix tree structures for interpreters with their own obmalloc state. Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
This commit is contained in:
parent
2d08af34b8
commit
7a7bce5a0a
9 changed files with 157 additions and 24 deletions
|
@ -32,6 +32,7 @@
|
|||
#include "pycore_typevarobject.h" // _Py_clear_generic_types()
|
||||
#include "pycore_unicodeobject.h" // _PyUnicode_InitTypes()
|
||||
#include "pycore_weakref.h" // _PyWeakref_GET_REF()
|
||||
#include "pycore_obmalloc.h" // _PyMem_init_obmalloc()
|
||||
|
||||
#include "opcode.h"
|
||||
|
||||
|
@ -645,6 +646,13 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
|
|||
return status;
|
||||
}
|
||||
|
||||
// initialize the interp->obmalloc state. This must be done after
|
||||
// the settings are loaded (so that feature_flags are set) but before
|
||||
// any calls are made to obmalloc functions.
|
||||
if (_PyMem_init_obmalloc(interp) < 0) {
|
||||
return _PyStatus_NO_MEMORY();
|
||||
}
|
||||
|
||||
PyThreadState *tstate = _PyThreadState_New(interp,
|
||||
_PyThreadState_WHENCE_INTERP);
|
||||
if (tstate == NULL) {
|
||||
|
@ -2144,6 +2152,14 @@ new_interpreter(PyThreadState **tstate_p, const PyInterpreterConfig *config)
|
|||
goto error;
|
||||
}
|
||||
|
||||
// initialize the interp->obmalloc state. This must be done after
|
||||
// the settings are loaded (so that feature_flags are set) but before
|
||||
// any calls are made to obmalloc functions.
|
||||
if (_PyMem_init_obmalloc(interp) < 0) {
|
||||
status = _PyStatus_NO_MEMORY();
|
||||
goto error;
|
||||
}
|
||||
|
||||
tstate = _PyThreadState_New(interp, _PyThreadState_WHENCE_INTERP);
|
||||
if (tstate == NULL) {
|
||||
status = _PyStatus_NO_MEMORY();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue