[Tutor] Memory Gotchas?

alan.gauld@bt.com alan.gauld@bt.com
Fri, 2 Mar 2001 11:24:29 -0000


> I would appreciate being pointed towards documentation on Python
> memory allocation.

Well, in principle you shouldn't need to worry since 
the garbage collector will do it for you. If you try 
to be too clever and anticipate what the GC does you 
run the risk of writing code that won't work as expected 
in later versiuons of Python. Its usually better to 
just trust the GC...

But if you must find out whats happening under the hood 
you can look at the Python Reference Manual about the 
Garbage Collector. ISTR it has pretty good descriptions 
of just what is colleted and when.

> I'm especially interested in avoiding coding mistakes which 
> could lead to memory leaks.

AFAIK, aside from circular references, there aren't too many 
possibilities. Its not like C/C++

Alan g.