Break reference cycles by calling gc.collect Objects can call other objects' methods (for instance, another object's __del__) inside their own __del__. On PyPy, the interpreter only runs between calls to gc.collect, so multiple calls are needed to completely release all cycles.
()
| 2367 | |
| 2368 | |
| 2369 | def break_cycles(): |
| 2370 | """ |
| 2371 | Break reference cycles by calling gc.collect |
| 2372 | Objects can call other objects' methods (for instance, another object's |
| 2373 | __del__) inside their own __del__. On PyPy, the interpreter only runs |
| 2374 | between calls to gc.collect, so multiple calls are needed to completely |
| 2375 | release all cycles. |
| 2376 | """ |
| 2377 | |
| 2378 | gc.collect() |
| 2379 | if IS_PYPY: |
| 2380 | # a few more, just to make sure all the finalizers are called |
| 2381 | gc.collect() |
| 2382 | gc.collect() |
| 2383 | gc.collect() |
| 2384 | gc.collect() |
| 2385 | |
| 2386 | |
| 2387 | def requires_memory(free_bytes): |
no outgoing calls