From: Markus G. <m.g...@gm...> - 2006-09-15 10:17:33
|
On 9/15/06, Markus Gritsch <m.g...@gm...> wrote: > On 9/15/06, Hiroki Tamakoshi <hir...@be...> wrote: > > > > On Fri, 15 Sep 2006 11:30:11 +0200 > > "Markus Gritsch" <m.g...@gm...> wrote: > > > > > Because you cannot explicitely delete an object. By calling del on a > > > variable which holds a reference to it, you just remove this > > > particular reference to the object. If it was the last reference > > > pointing to the object, the garbage collector can decide to free the > > > actual memory *at some time*. You can tell the garbage collector to > > > collect all objects which are no longer referenced by calling > > > gc.collect() > > > > calling gc.collect() doesn't change the memory usage. > > (Dan's patch is applied) > > > > obj_list = [] > > for i in xrange( 1000 ): > > obj = SomeObject( parameters ... ) > > obj_list.append( obj ) # memory grows > > > > for obj in obj_list: > > obj.expire() # clear cache > > > > del obj_list > > gc.collect() # <- added here, memory usage doesn't change. > > What if you omit expiring every single object and do a > > sqlhub.processConnection.cache.clear() > > instead? Something like obj_list = [] for i in range( 1000 ): obj = SomeObject( parameters ... ) obj_list.append( obj ) # memory grows del obj_list sqlhub.processConnection.cache.clear() gc.collect() # maybe skip this -- I never explicitly force the gc to collect. |