module imports and memory usage

Carlos Ribeiro carribeiro at
Wed Dec 1 19:01:59 CET 2004

On Tue, 30 Nov 2004 16:46:43 -0500, Brad Tilley <bradtilley at> wrote:
> I discovered that when I wrap my code up in a function def and call it
> that it uses around 4.6 MB of RAM all the time... even while sleeping.
> However, when I don't put it in a function def it uses around 2.6MB of
> data when it executes and only 100KB while sleeping. Why is this?

Totally unchecked, popped up from somewhere between my ears.

Is it possible that (in some situations) the function object keeps a
reference to its locals() somewhere, in such a way that it never gets
collected? Just wondering...

Carlos Ribeiro
Consultoria em Projetos
mail: carribeiro at
mail: carribeiro at

More information about the Python-list mailing list