[Tutor] garbage collecting

Mark Lawrence breamoreboy at yahoo.co.uk
Wed Jan 8 09:15:43 CET 2014


On 08/01/2014 04:41, Keith Winston wrote:
> Iirc, Python periodically cleans memory of bits & pieces that are no
> longer being used. I periodically do something stupid -- I mean
> experimental -- and end up with a semi-locked up system. Sometimes it
> comes back,  sometimes everything after that point runs very slowly, etc.
>
> I just saw where I could do os.system('python'), but in restarting the
> interpreter I'd lose everything currently loaded: my real question
> involves merely pushing the garbage collector into action, I think.
>
> --
> Keith
>

I've never played with the garbage collector in 10+ years of using 
Pythom, so I think it unlikely you need it now.  Far more likely is that 
you've written an infinite loop, fix that and all other problems go 
away.  Also where would you call the GC?  Surely until you know where in 
your code the problem is, you don't know where to make the call.  Even 
then, if memory is being allocated and Python thinks it's still in use, 
calling the GC won't have any impact anyway.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list