Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How python stop-the-world when gc handling reference cycles?

Tags:

python

cpython

Is python gc.collect() a stop-the-world (STW) garbage collector?

If it is a STW garbage collector, where and when to stop the world?

I know python uses deterministic reference counting, and this do not need stop the world. However, when handling the cycles, does python need stop the world?

like image 941
user11942900 Avatar asked Aug 16 '26 07:08

user11942900


1 Answers

IMO it is indeed the STW garbage collector in CPython. Because each thread is required to acquire GIL before it runs, and GIL is never released in the cycle-finding routine (quote from PEP-703).

like image 100
coherence73 Avatar answered Aug 17 '26 21:08

coherence73



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!