Losing memory, is it a bug or am I doing this wrong
I have to deliver my program and thought it might be wise to check and
see if I have any memory leaks. I noticed it is but I'm pretty sure
it's not me the problem, I'm pretty neat about my pointers and always
try and make sure I clean after myself :).
If I'm doing this correctly can somebody else give me their results :
1) Create a new project.
2) Add Form2 : TForm; to the Var declaration
3) Add a button to the main form.
4) On the onclick event of the button add the following code
procedure TForm1.Button1Click(Sender: TObject);
Var
MyHeap : THeapStatus;
intI1, intI2 : Integer;
begin
MyHeap := GetHeapStatus;
intI1 := MyHeap.TotalAllocated;
Application.CreateForm(TForm,Form2);
Form2.ShowModal;
Form2.Free;
Form2 := nil;
MyHeap := GetHeapStatus;
intI2 := MyHeap.TotalAllocated;
MessageDlg('Mem 1 : ' + IntToStr(intI1) + ' Mem 2 : ' +
IntToStr(intI2),mtInformation,[mbOk],0);
end;
I get six{*word*249} bytes lost the first time this is executed and 0 loss for
any other times it is executed. I have absolutely no idea why though.
Unless MyHeap has nothing really to do with allocated memory and is
reporting god knows what.
Any feedback on this would be greatly appreciated.
--
Lior Amar
Computer Consultant
SCii Technologies
lior.a...@sncf.fr