mirror of
https://github.com/python/cpython.git
synced 2026-01-01 04:53:46 +00:00
[3.13] gh-142048: Fix lost gc allocations count on thread cleanup (GH… (#142506)
[3.13] gh-142048: Fix lost gc allocations count on thread cleanup (GH-142233)
(cherry picked from commit 49b1fb43f6)
Co-authored-by: Kevin Wang <kevmo314@gmail.com>
This commit is contained in:
parent
813bcffffc
commit
fda856f368
1 changed files with 8 additions and 0 deletions
|
|
@ -1743,6 +1743,14 @@ PyThreadState_Clear(PyThreadState *tstate)
|
|||
|
||||
// Remove ourself from the biased reference counting table of threads.
|
||||
_Py_brc_remove_thread(tstate);
|
||||
|
||||
// Flush the thread's local GC allocation count to the global count
|
||||
// before the thread state is cleared, otherwise the count is lost.
|
||||
_PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate;
|
||||
_Py_atomic_add_int(&tstate->interp->gc.generations[0].count,
|
||||
(int)tstate_impl->gc.alloc_count);
|
||||
tstate_impl->gc.alloc_count = 0;
|
||||
|
||||
#endif
|
||||
|
||||
// Merge our queue of pointers to be freed into the interpreter queue.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue