Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Include/internal/pycore_tracemalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ struct
__attribute__((packed))
#endif
tracemalloc_frame {
/* filename cannot be NULL: "<unknown>" is used if the Python frame
filename is NULL */
PyObject *filename;
/* Interned NUL terminated UTF-8 (surrogatepass) string.
Cannot be NULL: "<unknown>" is used if the Python frame filename
cannot be captured. */
const char *filename;
unsigned int lineno;
};

Expand Down Expand Up @@ -85,7 +86,7 @@ struct _tracemalloc_runtime_state {
Protected by TABLES_LOCK(). */
size_t peak_traced_memory;
/* Hash table used as a set to intern filenames:
PyObject* => PyObject*.
char* (NUL terminated UTF-8 string) => NULL.
Protected by the TABLES_LOCK(). */
_Py_hashtable_t *filenames;
/* Buffer to store a new traceback in traceback_new().
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_tracemalloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,8 +1056,8 @@ def test_track(self):
self.check_track(False)

def test_track_without_gil(self):
# check that calling _PyTraceMalloc_Track() without holding the GIL
# works too
# check that calling PyTraceMalloc_Track() without the GIL
# (detached thread state) still captures the Python traceback
self.check_track(True)

def test_track_already_tracked(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:mod:`tracemalloc` no longer acquires the :term:`GIL` nor creates a
temporary thread state to trace memory allocations: traceback frames now
store plain UTF-8 strings instead of Python str objects, and tracebacks are
captured using the Python thread state already associated with the calling
thread, even if it is not attached. Threads without a Python thread state
record the traceback as ``<unknown>``.
Loading
Loading