[Tutor] garbage collecting

Oscar Benjamin oscar.j.benjamin at gmail.com
Wed Jan 8 21:30:07 CET 2014


On Jan 8, 2014 5:51 PM, "Keith Winston" <keithwins at gmail.com> wrote:
>
> Well, thanks everyone. I get the picture. And there's nothing subtle
going on here: I'm playing around, trying to factor million-digit numbers
and the like. No biggie, this was interesting.

Million digit numbers will use up some memory. Perhaps a megabyte per
number. If you just hold one in memory and try to factor it then it
shouldn't lead to the problems you described. Or are you holding a list of
many million digit numbers? Or are they several hundred million digits?

The garbage collector has nothing to do with the memory usage of immutable
types like ints. There are deallocated instantly when the last reference
you hold is cleared (in CPython). So if you run out of memory because of
them then it is because you're keeping them alive in your own code. Running
the garbage collector with gc.collect cannot help with that.

Oscar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140108/15a93359/attachment-0001.html>


More information about the Tutor mailing list