I noticed that string grid is consuming huge amount of memory. I have like 15 000 rows and 30 cols with strings which I`m loading from DB.
qry_->DisableControls();
qry_->Prepare();
qry_->Open("SELECT * FROM FILES ORDER BY CP_CODE,REC_DATE,REC_TIME ASC");
qry_->FetchAll();
qry_->First();
TDataFields dataFields; ;
dataFields.SetQuery(qry_);
try
{
grid_->RowCount = qry_->RecordCount + 1;
grid_->BeginUpdate();
int i = 1;
while (!qry_->Eof)
{
updateGridCells(dataFields, i);
qry_->Next();
i++;
}
}
finally
{
grid->EndUpdate();
qry->EnableControls();
qry_->Close();
}
14 800 records are consuming around 2GB ram which stays occupied even after clearing the grid with grid_->Clear();
Any ideas what would cause this problem ?
Regards!
I'm not sure what is special about your data, but I tried to reproduce this here with following code applied to a default TAdvStringGrid:
procedure TForm1.Button1Click(Sender: TObject);
var
i,j: integer;
begin
advstringgrid1.RowCount := 15000;
advstringgrid1.ColCount := 30;
for i := 1 to advstringgrid1.ColCount - 1 do
for j := 0 to advstringgrid1.RowCount - 1 do
advstringgrid1.Cells[i,j] := 'cell'+inttostr(i)+':'+inttostr(j);
end;
and here, this only consumes 31MB.
Is updateGridCells doing something special? How can we reproduce this?
Issue is solved.
Just to be clear, I`m using:
- C++ Builder
- MadExcept plugin
Huge memory consuption is caused by MadExcept plugin when when memory leak check options is enabled.
Disabling the plugin solved the issue. Maybe i have to report it to the MadExcept developer.
Thank you for your time!
Thanks for informing.
I was not aware MadExcept could consume that much memory. Maybe it is indeed good to contact them.