Memory Leak with function "AddBitmap"

When adding a Bitmap to a cell of AdvStringGrid by using method "AddBitmap", this bitmap is not freed by AdvStringGrid at the destroy function. Hence there is a memory leak.


If I free the graphics myself with
AdvSG.CellGraphics[c, r].Free
I get an access violation (EInvalidPointer) at the detroy method in AdGrid Unit at "if Assigned(FScrollTimer) then" line

Or do I missunderstand something?

sorry, the Access Violation is one line above at "ClearRect(0,0,CCnt - 1,RCnt - 1);"

In the ClearRect procedure it is the "FreeCellGraphic(rc,j);" line that causes the exception (what makes sense).

If I only release the CellBitmap with:
CellGraphics[1, i].CellBitmap.Free;
at the OnFormDestroy Event, the memory leak is gone. But I guess that should be part of the destructor of AdvStringGrid.

When you add a bitmap via grid.AddBitmap, the expected way to remove the bitmap again is via grid.RemoveBitmap().

Please use this way to remove the bitmap programmatically or you can also directly use grid.ClearRect() that will remove any cell graphic that might be in the rectangle.