You're not moving to the next record in your routine. It's sitting there 
looking at the same record over and over. A common mistake.

Dave

--- On Mon, 11/16/09, Brad Hall <brad.h...@semagroup.com.au> wrote:

From: Brad Hall <brad.h...@semagroup.com.au>
Subject: [delphi-en] Record memory issue
To: delphi-en@yahoogroups.com
Date: Monday, November 16, 2009, 7:22 PM







 



  


    
      
      
      Hi everyone,



I have a query about records + their memory usage.



I've created a record to hold a couple of values, which I then do a

quicksort (a separate procedure) on.



The drama is, the code never gets the chance to do the quicksort due to

the record consuming RAM at an unbelievable rate - hundreds of MB of RAM

until I get the "Out of Memory" error.



The values I'm loading into the record are a subset from a file only

1.01Mb in size (I've loaded the file into a TClientDataSet) .



I tried loading the same values that I was loading into the record into

a TStringList, + the resulting amount of memory used was less than 1Mb

(as it should be).



I also tried using a packed record but that didn't alleviate the problem

(I don't really like packed records either...).



The string values I'm loading into the record are only 1 character

each...



I don't see how the record is consuming so much memory! The only thing I

can think of at the moment is the way I'm allocating memory to the

record (SetLength).



Does anyone have any other ideas??



Code is:



procedure Process;



type 



TSortArr = record



Val: string;



Rec: cardinal;



end;  //type



var



SortArr: array of TSortArr;



SortStr: string;



RowCnt: cardinal;



begin 



RowCnt := 0;



while (NOT cdsInputFile. EOF) do



begin



SortStr := <data from cds>;



SetLength(SortArr, RowCnt + 1);



SortArr[RowCnt] .Val := SortStr;



SortArr[RowCnt] .FPos := cdsInputFile. RecNo;    



Inc(RowCnt);



ReadRecord;  //get next rec in file



end;  //while not eof



end;



Thanks :-)



[Non-text portions of this message have been removed]





    
     

    
    


 



  






      

[Non-text portions of this message have been removed]

Reply via email to