5

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?

amo-ej1
  • 3,279
  • 26
  • 35
  • 1
    Depends on the implementation. IronPython uses the GC from the CLR and Jython uses the JVM and even then the exact type of GC is not specified. This may give you some insight into the JVM GC (https://stackoverflow.com/questions/16695874/why-does-the-jvm-full-gc-need-to-stop-the-world) – MichaelD Aug 18 '19 at 20:21

1 Answers1

0

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).