Memory leak in Mac Python IDE ?

Daniel T. notdanielt3 at gte.net
Tue Jul 2 15:43:11 EDT 2002


"Louis M. Pecora" <pecora at anvil.nrl.navy.mil> wrote:

>I run the following code in a file under the IDE (under System 9.1 on a
>G4 Mac with 40 MB allocated to Python 2.2 IDE):
>
>#--Test code
>
>from Numeric import *
>
>tab1=zeros((200000,4))
>print shape(tab1)
>
>#--End Test code
>
>Check the memory under 'About this Computer' in the Finder.
>
>Then change tab1 to tab2 and run again (I hit cmd-R several times
>quickly and that seems to worsen the problem - don't know why), then
>check memory and see that more is used up.  Continue this process to
>tab3, tab4, etc. and eventually I get an exception -- ran out of
>memory, cannot allocate more.  Sure enough, under 'About this Computer'
>in the Finder, the memory is used up. 
>
>Looks like a memory leak to me, but maybe the IDE is set up to keep
>variables around, hence tab1, tab2, etc. are never garbage collected
>after the module is run with a new varible name, e.g. tab2 in place of
>tab1.
>
>Anyone know?

I take it you are running this in the "Python Interactive" window? Yes, 
the various objects you are creating stay around until you explicitly 
get rid of them. ie: del( tab1 ) will get rid of tab1 and free some 
memory.

-- 
Improve your company's understanding of objects...
Hire me. <http://home1.gte.net/danielt3/resume.html>



More information about the Python-list mailing list