Question about garbage collection

Michael Hudson mwh21 at cam.ac.uk
Thu Aug 3 14:22:14 EDT 2000


Donn Cave <donn at u.washington.edu> writes:

> Quoth nascheme at news.cnri.reston.va.us (Neil Schemenauer):
> | Donn Cave <donn at oz.net> wrote:
> |> I'd like to be able to invoke collection in a Python statement
> |> (one iteration at a time.)
> |
> | Compile Python with the configure option "--with-cycle-gc".
> | Then:
> |
> |     import gc
> |     gc.set_threshold(0)
> |     while some condition:
> |         do something
> |         gc.collect()
> |
> | will do want you want.  Currently collect() always does a full
> | collection.  There should probably be an option to do an
> | incremental collection.
> 
> Great, thanks.  I assume set_threshold(0) disables the automatic
> scheduling.  If that threshold were initially 0 in the default
> build, --with-cycle-gc could default to true and the user/program
> could choose rather than the admin/installer.  The latter seems
> like an awkward place to think about memory management strategies.

But the cost of the gc module is the overhead (in prcessor time and
memory) of keeping track of objects as they are created, not the time
taken to run the collection (or perhaps, there are other costs beyond
running the collection).  So there really is no other time to
decide...

Cheers,
M.

-- 
  Very rough; like estimating the productivity of a welder by the
  amount of acetylene used.         -- Paul Svensson, comp.lang.python
    [on the subject of the measuring programmer productivity by LOC]



More information about the Python-list mailing list