Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2018-05

fpWeb: How can I use heaptrc in standalone mode?

16 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marcos Douglas B. Santos

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.

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?

Lazarus 1.8.3 r57764 FPC 3.0.4 i386-win32-win32/win64

Marcos Douglas

Reply by email

Michael Van Canneyt
to Marcos Douglas B. Santos
Marcos Douglas B. Santos wrote 8 lines
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.

Show quoted text 6 lines
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.

Reply by email

Marcos Douglas B. Santos
to Michael Van Canneyt
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

Reply by email

Marcos Douglas B. Santos
to leledumbo
leledumbo wrote
> Create a call that calls Application.Terminate. I just call DumpHeap(false); instead

Where is this function or method? Could you give so more information how is this works with heaptrc?

About my test, do you have the same memleak?

Thanks.

Best,
Marcos Douglas

Reply by email

Marcos Douglas B. Santos
to Marcos Douglas B. Santos
Marcos Douglas B. Santos wrote 8 lines
On Sun, May 6, 2018 at 6:05 PM, leledumbo via fpc-pascal wrote: >> Create a call that calls Application.Terminate. > > I just call DumpHeap(false); instead Where is this function or method? Could you give so more information how is this works with heaptrc?

I saw that it's part or webutil unit... it is not the case here. But thanks.

About my test, do you have the same memleak?

Could you please do the same test?

Regards,
Marcos Douglas

Reply by email

Marcos Douglas B. Santos
to Marcos Douglas B. Santos: On Sat, May 5, 2018 at 11:51 AM, Michael Van Canneyt I believe there is a memleak but I…
Marcos Douglas B. Santos wrote 117 lines
On Sat, May 5, 2018 at 11:51 AM, Michael Van Canneyt wrote: > > > 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

Michael,
Would you want that I open a issue for it?

Regards,
Marcos Douglas

Reply by email

Michael Van Canneyt
to Marcos Douglas B. Santos
Marcos Douglas B. Santos wrote 12 lines
> Application.Run; > end. > > ===END=== > > My environment is: Lazarus 1.8.3 r57764 FPC 3.0.4 i386-win32-win32/win64 > > Best regards, > Marcos Douglas Michael, Would you want that I open a issue for it?

Allow me to test first, please.

Michael.

Reply by email

Marcos Douglas B. Santos
to Michael Van Canneyt
Michael Van Canneyt wrote 20 lines
On Mon, 7 May 2018, Marcos Douglas B. Santos wrote: >> Application.Run; >> end. >> >> ===END=== >> >> My environment is: Lazarus 1.8.3 r57764 FPC 3.0.4 i386-win32-win32/win64 >> >> Best regards, >> Marcos Douglas > > > Michael, > Would you want that I open a issue for it? Allow me to test first, please.

All right.
Let me know if you need a tester or more information. Thanks for your time.

Marcos Douglas

Reply by email

Michael Van Canneyt
to Marcos Douglas B. Santos
Marcos Douglas B. Santos wrote 25 lines
On Mon, May 7, 2018 at 6:05 PM, Michael Van Canneyt wrote: > > > On Mon, 7 May 2018, Marcos Douglas B. Santos wrote: > >>> Application.Run; >>> end. >>> >>> ===END=== >>> >>> My environment is: Lazarus 1.8.3 r57764 FPC 3.0.4 i386-win32-win32/win64 >>> >>> Best regards, >>> Marcos Douglas >> >> >> Michael, >> Would you want that I open a issue for it? > > > Allow me to test first, please. All right. Let me know if you need a tester or more information.

I tested it.

The memleak is present only in 3.0.4, no longer in trunk.

I remembered a similar bugreport by African Wild Dog:

https://bugs.freepascal.org/view.php?id=33535

where I had the same conclusion.

Michael.

Reply by email

Michael Van Canneyt
to Michael Van Canneyt
Michael Van Canneyt wrote 11 lines
> Let me know if you need a tester or more information. I tested it. The memleak is present only in 3.0.4, no longer in trunk. I remembered a similar bugreport by African Wild Dog: https://bugs.freepascal.org/view.php?id=33535 where I had the same conclusion.

Small addendum: someone reported that in the transition to the use of routes, the registering of modules suddenly became case sensitive.

I have fixed this, they are now case insensitive, but with the option to make it case sensitive. Also added the option to let an empty pattern match all URLS. Rev. 38956

Michael.

Reply by email

Marcos Douglas B. Santos
to Michael Van Canneyt: I tested it. The memleak is present only in 3.0.4, no longer in trunk. I remembered a…
Michael Van Canneyt wrote 45 lines
On Tue, 8 May 2018, Marcos Douglas B. Santos wrote: > On Mon, May 7, 2018 at 6:05 PM, Michael Van Canneyt > wrote: >> >> >> >> On Mon, 7 May 2018, Marcos Douglas B. Santos wrote: >> >>>> Application.Run; >>>> end. >>>> >>>> ===END=== >>>> >>>> My environment is: Lazarus 1.8.3 r57764 FPC 3.0.4 >>>> i386-win32-win32/win64 >>>> >>>> Best regards, >>>> Marcos Douglas >>> >>> >>> >>> Michael, >>> Would you want that I open a issue for it? >> >> >> >> Allow me to test first, please. > > > All right. > Let me know if you need a tester or more information. I tested it. The memleak is present only in 3.0.4, no longer in trunk. I remembered a similar bugreport by African Wild Dog: https://bugs.freepascal.org/view.php?id=33535 where I had the same conclusion.

OK sorry for didn't find this bugreport.
Is this fix in fixes_3_0 ?

Michael Van Canneyt wrote 8 lines
[...] Small addendum: someone reported that in the transition to the use of routes, the registering of modules suddenly became case sensitive. I have fixed this, they are now case insensitive, but with the option to make it case sensitive. Also added the option to let an empty pattern match all URLS. Rev. 38956

All right, thanks for the info.

Regards,
Marcos Douglas

Reply by email

Marcos Douglas B. Santos
to Michael Van Canneyt
Michael Van Canneyt wrote 7 lines
> > OK sorry for didn't find this bugreport. > Is this fix in fixes_3_0 ? I do not know, presumably not.

For "new things" I use to use the last version published, just to see that works.
Then, I start to use fixes_3_0.
I supposed that any fixes in trunk must be applied in fixes, don't?

Well, if I'm wrong, could you do that to this bug?

Regards,
Marcos Douglas

Reply by email

Michael Van Canneyt
to Marcos Douglas B. Santos
Marcos Douglas B. Santos wrote 14 lines
On Wed, May 9, 2018 at 9:31 AM, Michael Van Canneyt wrote: > >> >> OK sorry for didn't find this bugreport. >> Is this fix in fixes_3_0 ? > > > I do not know, presumably not. For "new things" I use to use the last version published, just to see that works. Then, I start to use fixes_3_0. I supposed that any fixes in trunk must be applied in fixes, don't?

Not necessarily. It depends on the plans for the next release.

Well, if I'm wrong, could you do that to this bug?

Marco Van de Voort usually handles this.

Michael.

Reply by email

Marcos Douglas B. Santos
to Michael Van Canneyt
Michael Van Canneyt wrote 25 lines
On Wed, 9 May 2018, Marcos Douglas B. Santos wrote: >>> OK sorry for didn't find this bugreport. >>> Is this fix in fixes_3_0 ? >> >> >> >> I do not know, presumably not. > > > For "new things" I use to use the last version published, just to see > that works. > Then, I start to use fixes_3_0. > I supposed that any fixes in trunk must be applied in fixes, don't? Not necessarily. It depends on the plans for the next release. > > Well, if I'm wrong, could you do that to this bug? Marco Van de Voort usually handles this.

Just for you and others know, it already was applied in fixes_3_0. My FPC rev is 38816.

Regards,
Marcos Douglas

Reply by email