In Python, most garbage is collected using reference counting. One would expect it to be quick and painless, and it is unlikely that this is what you need. I assume that you are asking about the collector referenced by the gc module, which is used only for circular references.
There are a few things that may be helpful: http://docs.python.org/library/gc.html
Despite the fact that there is no direct method for collecting the garbage collector, you can turn it on and off, enable debugging, view the collection count, etc. All this can be useful in your search.
For example, on my gc system, the elapsed time is printed if you enable debug flags:
In [1]: import gc In [2]: gc.set_debug(gc.DEBUG_STATS) In [3]: gc.collect() gc: collecting generation 2... gc: objects in each generation: 159 2655 7538 gc: done, 10 unreachable, 0 uncollectable, 0.0020s elapsed.
All this aside, the first thing I would like to draw attention to is the evolution of the memory usage of your program as it starts. One possibility is that it simply reaches the limit of available physical memory and slows down due to excessive page crashes, and not because of anything related to the garbage collector.
NPE
source share