Memory leak on TAdvStringGrid


When I access the CellProperties property of a grid(Latest version VCL UI PACK) I get the following memory leak report from FastMM:

Captura desde 2024-05-01 11-58-09

Any hints?

thanks in advance,

Omar Zelaya

  1. What exact code do you use?
  2. Do you get the leak with setting ReportMemoryLeaksOnShutDown = true?

GridItems.CellProperties[ACol,ARow].ReadOnly := true;
GridItems.CellProperties[ACol,ARow].BrushColor := clSilver;
ReportMemoryLeaksOnShutdown := True;

Thanks in advance,

Omar Zelaya

I see no leak here

procedure TForm1.FormCreate(Sender: TObject);
ReportMemoryLeaksOnShutdown := true;

advstringgrid1.CellProperties[1,1].ReadOnly := true;
advstringgrid1.CellProperties[1,1].BrushColor := clSilver;

I see a similar memory leak very occasionally in my application, but I've never found the cause or pattern.

One thing to always take care about is that when you would decrease grid.RowCount without clearing possible objects in cells in rows that will disappear due to this change in RowCount. So, do a ClearRect() before decreasing RowCount if this would be the case.

I've been doing this when clearing grids. They may or may not get repopulated after this. There is one fixed row and column.

  grid.RowCount := 2;

Should I be really do doing this instead?

  grid.RowCount := 2;

Yes, please use the 2nd approach