Hi Bob,
Thanks for the tips.
It a bit tricky to put the script as its a bit complex.
Its build in a way that there is a class that makes all calculations and
returns the output. Lets simplify:

class objX:
    def __init__(self, params):
        ....
    
    def method1 (self):
        ....

    def method2(self):
        ....
    def __str__(self):
        the output I need

## now there is a loop that reads the file

file = open(path, "r")
for line in file.xreadlines():
    x, y, z = line.split()
    NewObj = objX(x,y,z)
    NewObj.method1()
    NewObj.method2()
    print NewObj
file.close()

As you can see nothing should be stored. The objX class may contain whatever
methods needed and make complex calculations but it is reused after each
line is read. Right?
Suppose there is a memory leak in one of the methods. Shouldn't it be
released once a new line is read and an object with the exact same name is
created? Is it possible that the NewObj created after each line doesn't
removed from memory the previous NewObj?

Yair


on 21/4/2005 21:16, Bob Ippolito at [EMAIL PROTECTED] wrote:

> 
> On Apr 21, 2005, at 10:06 AM, Yair Benita wrote:
> 
>> I am using python 2.3 on Panther and have a question.
>> I use python to read a huge 1Gb text file, one line at a time.
>> For each line a functions is performed and the result is written to an
>> output file. No information should accumulate as the file is being
>> read and
>> yet, the first few thousands line go very very fast and then the
>> program
>> slows down gradually.
>> Any idea what could go wrong. I can't think of any memory leak as most
>> of
>> the script is fairly simple. Also, looking at the Activity Monitor I
>> don't
>> see that it takes huge amounts of RAM and there is plenty of free
>> memory
>> available.
> 
> Test with Python 2.4.1.  Panther's 2.3.0 is quite old and has a few
> known bugs (though none that would cause this behavior that I know of).
>   If you get the same results with 2.4.1 then post the script.
> Presumably if it's not a Python 2.3.0 bug, then doing something wrong,
> and we can only guess what that is unless you show the script.
> 
> -bob
> 


_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to