[Tutor] memory error files over 100MB

Kent Johnson kent37 at tds.net
Tue Mar 17 14:02:44 CET 2009


On Tue, Mar 17, 2009 at 6:34 AM, A.T.Hofkamp <a.t.hofkamp at tue.nl> wrote:

>> http://personalpages.tds.net/~kent37/kk/00012.html
>
> Nice web-page!

Thanks!

> You can do the above statements also iteratively of course
>
> for i in ...
>  s = read()
>  # write s
>
> but since the loop does nothing with either s or read(), this will not
> change how the assignment works.
>
>
> In the case that you are manipulating large values (as in taking a lot of
> computer memory for each value), the execution of the read() during step 3
> may fail due to memory being used for the previously assigned value of s.

Ah, thanks, I misunderstood the point you were making.

You can allow the previous value of s to be garbage-collected by
assigning s=None, for example:

for i in ...
  s = read()
  # process s
  s = None

Kent


More information about the Tutor mailing list