View Single Post
Old 11-02-2010, 11:14 AM
Mike Halliday Mike Halliday is offline
Senior Member
Join Date: Sep 2007
Location: Warrington, United Kingdom
Posts: 821
Send a message via Skype™ to Mike Halliday
Default Memory leak in ReadString?

I have an application that reads lines from a text file, parses the string and writes a new text file depending on the input string;

The source file is 1.813MB in size (Not massive, but big) and is a dump from Active Directory (50 lines per record, blank line as next record marker) - There are 56,335 lines total in the file.

The destination is a .CSV file.

I open both files (Source as read only) (Destination as write)

Pseudo code:

While (FEOF(input) == 0)
line = readstring(input)

if (mid(line,0,13) == "printername: ")
output = output + Mid(line,14, length(line))

<6 more checks for specific lines in the input file>

if (mid(line,0,1) == " ") // end of this current record


My app seeks through about 13 complete records then throws an exception error. (Access Violation at 0x40e223)

I cant see why, other than PPL is running out of memory.

Is there a known memory leak with ReadString?

I have tried loading the whole file into a string to manipulate as a list, but it too runs out of memory (How big can a string be? - Not 1.8MB I guess!)

Frustrating me now, as all I am trying to do is open a file, read the lines in succession then output to another file when criteria is found. - Not asking much!

Oh, and I have tried this in 1.53 and 2.2.1 and both do the same thing.

Any suggestions guys?

<EDIT> - Ok, so I have run my code on 2 different machines and get the same problem. Machine 1 is W7 with 3GB ram and Machine 2 is XPSP3 with 1GB ram. Both fall over at roughly the same place.

Got to be memory related as the machine with 1GB warned me about Virtual Memory being low, just before it fell over.

Last edited by Mike Halliday; 11-02-2010 at 12:25 PM.
Reply With Quote