fpWeb: How can I use heaptrc in standalone mode?

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

fpWeb: How can I use heaptrc in standalone mode?

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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Michael Van Canneyt


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.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Marcos Douglas B. Santos
On Sat, May 5, 2018 at 11:51 AM, Michael Van Canneyt
<[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Free Pascal - General mailing list
In reply to this post by Michael Van Canneyt
> Create a call that calls Application.Terminate.

I just call DumpHeap(false); instead



--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Marcos Douglas B. Santos
On Sun, May 6, 2018 at 6:05 PM, leledumbo via fpc-pascal
<[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Marcos Douglas B. Santos
On Sun, May 6, 2018 at 6:26 PM, Marcos Douglas B. Santos <[hidden email]> wrote:
> On Sun, May 6, 2018 at 6:05 PM, leledumbo via fpc-pascal
> <[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Marcos Douglas B. Santos
In reply to this post by Marcos Douglas B. Santos
On Sun, May 6, 2018 at 5:44 PM, Marcos Douglas B. Santos <[hidden email]> wrote:

> On Sat, May 5, 2018 at 11:51 AM, Michael Van Canneyt
> <[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Michael Van Canneyt


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.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Marcos Douglas B. Santos
On Mon, May 7, 2018 at 6:05 PM, Michael Van Canneyt
<[hidden email]> 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.
Thanks for your time.

Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Michael Van Canneyt


On Tue, 8 May 2018, Marcos Douglas B. Santos wrote:

> On Mon, May 7, 2018 at 6:05 PM, Michael Van Canneyt
> <[hidden email]> 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.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Michael Van Canneyt


On Wed, 9 May 2018, Michael Van Canneyt wrote:

>> 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.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Marcos Douglas B. Santos
In reply to this post by Michael Van Canneyt
On Wed, May 9, 2018 at 3:47 AM, Michael Van Canneyt
<[hidden email]> wrote:

>
>
> On Tue, 8 May 2018, Marcos Douglas B. Santos wrote:
>
>> On Mon, May 7, 2018 at 6:05 PM, Michael Van Canneyt
>> <[hidden email]> 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 ?


On Wed, May 9, 2018 at 4:38 AM, Michael Van Canneyt
<[hidden email]> wrote:
>
> [...]
> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Michael Van Canneyt


On Wed, 9 May 2018, Marcos Douglas B. Santos wrote:

>> 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 ?

I do not know, presumably not.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Marcos Douglas B. Santos
On Wed, May 9, 2018 at 9:31 AM, Michael Van Canneyt
<[hidden email]> 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?

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

Regards,
Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Michael Van Canneyt


On Wed, 9 May 2018, Marcos Douglas B. Santos wrote:

> On Wed, May 9, 2018 at 9:31 AM, Michael Van Canneyt
> <[hidden email]> 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.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpWeb: How can I use heaptrc in standalone mode?

Marcos Douglas B. Santos
On Wed, May 9, 2018 at 10:48 AM, Michael Van Canneyt
<[hidden email]> wrote:

>
>
> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal