
Simon Sapin, 03.05.2013 13:16:
Le 03/05/2013 12:32, Stefan Behnel a écrit :
Kai Hoppert, 03.05.2013 11:06:
a solution i found for solving this problem was
import mymodule.parser_file
for f in index: d = parser_file.MyParser.parse(f)
#Now do everything you want to do with the parsed information reload(mymodule.parser_file)
The python buildin reload for modules seems to be cleaning up the reference stuff holding by the parser.
I can't see why it should. Could you make sure you are talking about the same issue as discussed in this thread?
I don’t have the beginning of the thread
It started in October 2011. And as I suggested, it looks unrelated.
but it looks like the module reloading is only a convoluted way to release the last reference to the parser object.
So the question is: does parsing many files with the same parser object leak memory, compared to creating a parser object every time and releasing it? (Of course, having the rest of the code would help.)
If you repeatedly call parse() in the main thread, you'll always get the same parser. So, no, there's nothing special about reusing parsers.
Stefan