A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-April/023241.html below:

[Python-Dev] A "new" kind of leak

[Python-Dev] A "new" kind of leakTim Peters tim.one@comcast.net
Sun, 14 Apr 2002 15:50:31 -0400
[Neil Schemenauer]
> PyCFunctionObject and PyMethodObject also use free lists and set the GC
> flag.

I haven't yet been able to provoke unbounded process growth using these,
although I confess I haven't dedicated my life to it <wink>.  The usual
outcome is that creating one of these guys also involves creating another
kind of gc'ed object (like a class instance) that doesn't use a free list,
and that's also involved in the cycle, and then the allocations of that
latter kind of object trigger gc regularly.

For example,

import gc
gc.set_debug(gc.DEBUG_STATS)

class C:
    def f(self):
        self.f = self.f   # create a loop

while 1:
    C().f()

That creates tons of cycles, but every 1000-or-so times around the loop, the
excess of instance objects allocated triggers gc into cleaning them all up.
That prevents the bound method object free list from growing more than
1000-or-so entries too.





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4