I can confirm a memory leak with both NewDIBBitmap and NewBitmap.
Tested with KOL v3 and v2 - so maybe it is just how memory is allocated.
The following sample program will demonstrate the memory usage:
program Test;
uses
Windows, Messages, KOL;
var
DIBBitmap: PBitmap;
lblHeap: PControl;
procedure btnCreateClick(Dummy: Pointer; Sender: PObj);
begin
if Assigned(DIBBitmap) then
Free_And_Nil(DIBBitmap);
DIBBitmap := NewDIBBitmap(ScreenWidth, ScreenHeight, pf24bit);
end;
procedure btnFillClick(Dummy: Pointer; Sender: PObj);
var
DC: HDC;
begin
if not Assigned(DIBBitmap) then
Exit;
DC := GetDC(GetDesktopWindow);
BitBlt(DIBBitmap.Canvas.Handle, 0, 0, DIBBitmap.Width, DIBBitmap.Height, DC, 0, 0, SRCCOPY);
ReleaseDC(GetDesktopWindow, DC);
end;
procedure btnSaveClick(Dummy: Pointer; Sender: PObj);
begin
if Assigned(DIBBitmap) then
DIBBitmap.SaveToFile(ChangeFileExt(ParamStr(0), '.bmp'));
end;
procedure btnFreeClick(Dummy: Pointer; Sender: PObj);
begin
if Assigned(DIBBitmap) then
Free_And_Nil(DIBBitmap);
end;
procedure TimerTick(Dummy: Pointer; Sender: PObj);
var
HeapStatus: THeapStatus;
begin
HeapStatus := GetHeapStatus;
lblHeap.Caption := Int2Str(HeapStatus.TotalAllocated);
end;
begin
Applet := NewForm(nil, 'DIBBitmap Test');
with NewButton(Applet, 'Create')^ do
OnClick := TOnEvent(MakeMethod(nil, @btnCreateClick));
with NewButton(Applet, 'Fill').PlaceDown^ do
OnClick := TOnEvent(MakeMethod(nil, @btnFillClick));
with NewButton(Applet, 'Save').PlaceDown^ do
OnClick := TOnEvent(MakeMethod(nil, @btnSaveClick));
with NewButton(Applet, 'Free').PlaceDown^ do
OnClick := TOnEvent(MakeMethod(nil, @btnFreeClick));
lblHeap := NewLabel(Applet,'Heap Status').PlaceDown.ResizeParent;
with NewTimer(500)^ do
begin
OnTimer := TOnEvent(MakeMethod(nil, @TimerTick));
Enabled := True;
end;
Run(Applet);
end.