Question about garbage collection

Donn Cave donn at u.washington.edu
Thu Aug 3 12:27:48 EDT 2000


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.

I like Rainer Dreyke's get_unreferenced() idea, too.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list