(UPDATE) Memory problems (garbage collection)

Carbon Man darwin at nowhere.com
Fri Apr 24 05:52:28 CEST 2009

Thanks for the replies. I got my program working but the memory problem 
remains. When the program finishes and I am brought back to the PythonWin 
the memory is still tied up until I run gc.collect(). While my choice of 
platform for XML processing may not be the best one (I will change it later) 
I am still concerned with the memory issue. I can't believe that it could be 
an ongoing issue for Python's xml.dom, but nobody was able to actually point 
to anything in my code that may have caused it? I changed the way I was 
doing string manipulation but, while it may have been beneficial for speed, 
it didn't help the memory problem.
This is more nuts and bolts than perhaps a newbie needs to be getting into 
but it does concern me. What if my program was a web server and periodically 
received these requests? I decided to try something:

if __name__ == '__main__':
    replicate = reptorParsing()
    replicate.process(filename=os.path.join(os.getcwd(), "request.xml"))
    import gc

Fixed the problem, though I wouldn't know why. Thought it might be something 
to do with my program but...

if __name__ == '__main__':
    replicate = reptorParsing()
    replicate.process(filename=os.path.join(os.getcwd(), "request.xml"))
    del replicate

Did not resolve the memory problem.

Any ideas? 

More information about the Python-list mailing list