I want to show memory leaks in a console app but when using ExitProcess(0)
it doesn't show them and without it i don't know how i can quit the app.
This is an example of code that creates a memory leak but doesn't show it:
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
sysutils, classes, windows;
function Test: Boolean;
var
test : TStringList;
begin
test := TStringList.Create;
ExitProcess(0);
end;
begin
try
ReportMemoryLeaksOnShutdown := true;
Test;
except
on E: Exception do
begin
Writeln(E.ClassName, ': ', E.Message);
REadln;
end;
end;
end.
To see the memory leaks I execute the exe from a cmd. Now if I comment ExitProcess
I can see them but with it on I can't. Is there a fix for that?