Re: Interpreter memory use/leak

Guido.van.Rossum@cwi.nl
Thu, 02 Feb 1995 09:52:36 +0100

> Reading largish lists and dictionaries from a .py seems to
> gobble up all sorts of memory that is not freed until the
> interpreter terminates. The same source when imported via a
> .pyc takes a fraction of the ram. It could be I'm using a
> non-optimal syntax. The .py file looks like:
>
> var={'abc':123,
> 'ccc': 222,
> # 10K lines or so
> 'zzz':333 }
>
> Is there a better way to use static lists. Marshal seems to
> be slower than the .pyc.

This must be the parse tree, which gets rather large for that kind of
usage. The memory will be freed, but it may cause fragmentation (and
of course if you're running on a machine without virtual memory your
process size will have grown permanently).

I can't believe marshal is slower than .pyc, since .pyc *uses*
marshal. So I would recomment marshal to do this.

--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>