Michael Van Canneyt wrote 26 lines
On Sat, 5 May 2018, Marcos Douglas B. Santos wrote:
> I'm using fpWeb in standalone mode (fphttpapp unit) to develop and debug.
> I would like to see the heaptrc log in the end, as we can do in normal
> desktop applications.
>
> So, in one route I create an object and don't release it to simulate a
> memleak.
>
> I've tried to set heaptrc.SetHeapTraceOutput('log.txt'). The app
> creates the file, but there is no log there.
This is definitely necessary.
>
> I've tried to execute using F9 IDE and by command-line too.
> I think the problem is that we need to kill the server (Ctrl+C) and,
> because that, no log is created.
>
> So, how can I see the log?
Create a call that calls Application.Terminate.
Michael,
I believe there is a memleak but I couldn't found. I've just created a route that calls Application.Terminate and I got this:
===BEGIN===
Heap dump by heaptrc unit
387 memory blocks allocated : 18658/19944
385 memory blocks freed : 18626/19912
2 unfreed memory blocks : 32
True heap size : 196608 (96 used in System startup) True free heap : 196320
Should be : 196352
Call trace for block $034CA470 size 16
$0042D3C1
$00438926
$004375AA
$00437268
$004265FB
$BAADF00D
$BAADF00D
$BAADF00D
Call trace for block $034CA410 size 16
$0042CE3B
$0042D3C1
$00438926
$004375AA
$00437268
$004265FB
$BAADF00D
$BAADF00D
===END===
Here is my test program:
===BEGIN===
program demo;
{$define STANDALONE}
uses
SysUtils,
httpdefs, httproute,
{$ifdef STANDALONE}
fphttpapp,
{$endif}
{$ifdef FCGI}
fpfcgi,
{$endif}
IniFiles;
{$ifdef STANDALONE}
procedure TerminateCallBack({%H-}ARequest: TRequest; {%H-}AResponse: TResponse);
begin
Application.Terminate;
end;
procedure ConfigureStandalone;
begin
heaptrc.SetHeapTraceOutput('log.txt');
heaptrc.GlobalSkipIfNoLeaks := True;
heaptrc.HaltOnError := False;
with TIniFile.Create('demo.ini') do
try
Application.Port := ReadInteger('Standalone','Port',8080);
finally
Free;
end;
HTTPRouter.RegisterRoute('quit', rmAll, @TerminateCallBack, True);
end;
{$endif}
begin
{$ifdef STANDALONE}
ConfigureStandalone;
{$endif}
Application.Initialize;
Application.Run;
end.
===END===
My environment is: Lazarus 1.8.3 r57764 FPC 3.0.4 i386-win32-win32/win64
Best regards,
Marcos Douglas