[issue26530] tracemalloc: add C API to manually track/untrack memory allocations

STINNER Victor report at bugs.python.org
Thu Mar 10 09:34:20 EST 2016


STINNER Victor added the comment:

Patch without test.

I chose to require the GIL to be held for efficiency. IMHO the common case is more than the GIL is held.

Example to call the function if the GIL is not held:

    int res;
    PyGILState_STATE gil_state;
    gil_state = PyGILState_Ensure();
    res = _PyTraceMalloc_Track(ptr, size);
    PyGILState_Release(gil_state);
    return res;

See also my numpy pull request on PyMem_Malloc() called without the GIL being held:
https://github.com/numpy/numpy/pull/7404

----------
keywords: +patch
Added file: http://bugs.python.org/file42115/tracemalloc_track.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26530>
_______________________________________


More information about the Python-bugs-list mailing list