mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-93502: Add new C-API functions to trace object creation and destruction (#115945)
This commit is contained in:
parent
2770d5caca
commit
6bcbee09df
10 changed files with 207 additions and 8 deletions
|
@ -906,6 +906,10 @@ _PyTraceMalloc_Start(int max_nframe)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (PyRefTracer_SetTracer(_PyTraceMalloc_TraceRef, NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tracemalloc_config.tracing) {
|
||||
/* hook already installed: do nothing */
|
||||
return 0;
|
||||
|
@ -1352,8 +1356,12 @@ _PyTraceMalloc_Fini(void)
|
|||
Do nothing if tracemalloc is not tracing memory allocations
|
||||
or if the object memory block is not already traced. */
|
||||
int
|
||||
_PyTraceMalloc_NewReference(PyObject *op)
|
||||
_PyTraceMalloc_TraceRef(PyObject *op, PyRefTracerEvent event, void* Py_UNUSED(ignore))
|
||||
{
|
||||
if (event != PyRefTracer_CREATE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
assert(PyGILState_Check());
|
||||
|
||||
if (!tracemalloc_config.tracing) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue