Hi Dave,

The procedure ReadRecord is used to move to the next record in the
clientdataset.

I'm also using a progressbar to track the progress of the reads from the
clientdataset (using .RecordCount as the progressbar.Max + .Recno as the
progressbar.Position), so I know the record pointer is moving thru the
records in the dataset.

 

Forgot to mention, there's 35,000 records being read + loaded into the
TRecord - not a large amount.

 

:-)

 

________________________________

From: [email protected] [mailto:[email protected]] On
Behalf Of David Smith
Sent: Tuesday, 17 November 2009 8:03 PM
To: [email protected]
Subject: Re: [delphi-en] Record memory issue

 

  

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 <[email protected]
<mailto:brad.hall%40semagroup.com.au> > wrote:

From: Brad Hall <[email protected]
<mailto:brad.hall%40semagroup.com.au> >
Subject: [delphi-en] Record memory issue
To: [email protected] <mailto:delphi-en%40yahoogroups.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]





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

Reply via email to