how to create uncollectable garbage in python? -
i have large long-running server, and, on weeks memory usage steadily climbs.
generally, pointed out below, unlikely leaks problem; however, have not got lot go on want see if there leaks.
getting @ console output tricky i'm not running gc.set_debug()
. not big problem though, have added api run gc.collect()
, iterate through gc.garbage
, send results out me on http.
my problem running locally short time gc.garbage
empty. can't test bit of code lists leaks before deploy it.
is there trivial recipe creating uncollectable bit of garbage can test code lists garbage?
any cycle of finalizable objects (that is, objects __del__
method) uncollectable (because garbage collector not know order run finalizers in):
>>> class finalizable: ... def __del__(self): pass ... >>> = finalizable() >>> b = finalizable() >>> a.x = b >>> b.x = >>> del >>> del b >>> import gc >>> gc.collect() 4 >>> gc.garbage [<__main__.finalizable instance @ 0x1004e0b48>, <__main__.finalizable instance @ 0x1004e73f8>]
but general point, seems unlikely me problem due uncollectable garbage, unless in habit of using finalizers. it's more due accumulation of live objects, or fragmentation of memory (since python uses non-moving collector).
Comments
Post a Comment