On Friday 15 September 2006 12:41, Hiroki Tamakoshi wrote: > On Fri, 15 Sep 2006 11:30:11 +0200 > > "Markus Gritsch" <[EMAIL PROTECTED]> 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.
If I recall correctly python allocates memory of the OS in chunks and then has an internal memory allocator which allocates from these chunks. Which means that it may not return it to the OS but keep it for later reuse. Here a very simple test: [EMAIL PROTECTED]:~$ python >>> # ps aux here shows 4060 2552 (VSZ and RSS in kb) >>> l = range(1000000) >>> # ps aux here shows 19848 18272 (VSZ and RSS in kb) >>> del l >>> # ps aux here shows 15940 14364 (VSZ and RSS in kb) >>> # calling gc.collect() below will have no effect since we have >>> # no garbage actually, but is included just for reference >>> import gc; gc.collect() >>> # ps aux here shows 15940 14364 (VSZ and RSS in kb) >>> Which shows what I said (the above was a clean python interpreter with only a list created and destroyed). So this is not a SQLObject problem, but rather your misunderstanding of how memory allocation should behave. As I already said, with or without my patch a circular reference problem will not be apparent unless you enable memory tracing, because else the gc will do it's job, but with a performance cost without the patch. -- Dan ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss