View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0023647 | FPC | FCL | public | 2013-01-14 11:43 | 2013-01-21 14:17 |
Reporter | silvioprog | Assigned To | Marco van de Voort | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Product Version | 2.7.1 | ||||
Fixed in Version | 3.0.0 | ||||
Summary | 0023647: DaemonApp leak? | ||||
Description | Hi, Please just open and test the demo in attached. It will generate this output: Heap dump by heaptrc unit 99 memory blocks allocated : 3531/3744 89 memory blocks freed : 3147/3352 10 unfreed memory blocks : 384 True heap size : 360448 (112 used in System startup) True free heap : 359168 Should be : 359304 Call trace for block $0159EB68 size 16 $0041ED4D $0041C8AA $0041C637 $0041BC57 $0041EE4B $0041AD9B $0042D894 $004017F4 main, line 12 of project1.lpr Call trace for block $015A5BB8 size 36 $0041C637 $0041BC57 $0041EE4B $0041AD9B $0042D894 $004017F4 main, line 12 of project1.lpr $0040E58F Call trace for block $015BD860 size 56 $0041BC57 $0041EE4B $0041AD9B $0042D894 $004017F4 main, line 12 of project1.lpr $0040E58F Call trace for block $0159EB08 size 16 $0040A418 $0041BC48 $0041EE4B $0041AD9B $0042D894 $004017F4 main, line 12 of project1.lpr $0040E58F Call trace for block $015DD800 size 80 $0041EE4B $0041AD9B $0042D894 $004017F4 main, line 12 of project1.lpr $0040E58F Call trace for block $0159EAA8 size 16 $0040A418 $004239C3 $0041BE96 $004192BC TBROOKHTTPDAEMONMAPPER__CREATE, line 112 of daemon.pas $0041AD9B $0042D894 $004017F4 main, line 12 of project1.lpr $0040E58F Call trace for block $0159EA48 size 16 $004233A3 $004239C3 $0041BE96 $004192BC TBROOKHTTPDAEMONMAPPER__CREATE, line 112 of daemon.pas $0041AD9B $0042D894 $004017F4 main, line 12 of project1.lpr $0040E58F Call trace for block $0159E9E8 size 16 $0041ED4D $0041BA28 $0041BD82 $0041BE86 $004192BC TBROOKHTTPDAEMONMAPPER__CREATE, line 112 of daemon.pas $0041AD9B $0042D894 $004017F4 main, line 12 of project1.lpr Call trace for block $015A5B48 size 36 $0041BD82 $0041BE86 $004192BC TBROOKHTTPDAEMONMAPPER__CREATE, line 112 of daemon.pas $0041AD9B $0042D894 $004017F4 main, line 12 of project1.lpr $0040E58F Call trace for block $015D57F8 size 96 $0041AD9B $0042D894 $004017F4 main, line 12 of project1.lpr $0040E58F Thank you! | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 23480 | ||||
FPCOldBugId | |||||
FPCTarget | |||||
Attached Files |
|
2013-01-14 11:43
|
|
|
Full source code of BrookFCLHTTPDaemonBroker.pas: https://github.com/silvioprog/brookframework/issues/11 Thank you! |
|
That seems to be in the call to DaemonDefs.Add in the constructor. String allocations that keep at least a refcount of one and class allocations w/o free. This is normally not a problem for a Daemon, because the memory will be free'd once the Daemon is uninstalled. *edit* Although not very elegant, I think this is by design. |
|
But its possible to solve it? |
|
Yes. f.e. add an interface to DaemonDefs and instantiate it through the interface. This will not break existing code and gets rid of the "leaks". btw: nice work that brookframework! But plz provide clear links to dependency packages on the website. |
|
The problem is that you can not safely call the destructor on DaemonDefs, because this may give hard to predict results, so the design simply does not call it at all.. In this case adding the free call to a finalization section may lead to problems because the order in which the finalization sections are processed is by definition undefined. A iinterface solves this. In its simplest form you only have to add IInterface, instantiate through the interface and hardcast back to the DaemonDefs class type. The marshalling ensures the destructor gets called at a convenient time. I am not sure it is warranted to provide a patch (not everybody likes interfaces) but it is trivial and I am happy to do so if the maintainers of the code wish. |
|
> Yes. f.e. add an interface to DaemonDefs and instantiate it through the interface. This will not break existing code and gets rid of the "leaks". Can you send me a sample code? > btw: nice work that brookframework! But plz provide clear links to dependency packages on the website. Thank you. :) We can create a file "DEPENDENCIES.txt" with the text "All dependencies used in this project", and below all links of it. |
|
>I am not sure it is warranted to provide a patch (not everybody likes interfaces) but it is trivial and I am happy to do so if the maintainers of the code wish. Feel totally free to implement it. :) After done, send your patch to this issue: https://github.com/silvioprog/brookframework/issues/11 Thank you! |
|
News? :) |
2013-01-21 12:14
|
daemonapp.pp-20120121-0844.patch (380 bytes)
Index: packages/fcl-extra/src/daemonapp.pp =================================================================== --- packages/fcl-extra/src/daemonapp.pp (revision 23467) +++ packages/fcl-extra/src/daemonapp.pp (working copy) @@ -929,6 +929,7 @@ begin if assigned(FEventLog) then FEventLog.Free; + inherited Destroy; end; procedure TCustomDaemonApplication.DoRun; |
|
Guys, I solved the problem. In attached the patch that eliminates the memory leak. Thank you! |
|
Committed, thanks |
|
Working like a charm, thank you! |
Date Modified | Username | Field | Change |
---|---|---|---|
2013-01-14 11:43 | silvioprog | New Issue | |
2013-01-14 11:43 | silvioprog | File Added: daemon.zip | |
2013-01-14 12:09 | silvioprog | Note Added: 0064876 | |
2013-01-14 12:10 | silvioprog | Note Edited: 0064876 | |
2013-01-14 16:35 | Thaddy de Koning | Note Added: 0064878 | |
2013-01-14 16:38 | Thaddy de Koning | Note Edited: 0064878 | |
2013-01-14 16:38 | Thaddy de Koning | Note Edited: 0064878 | |
2013-01-16 21:48 | silvioprog | Note Added: 0064927 | |
2013-01-17 06:22 | Thaddy de Koning | Note Added: 0064933 | |
2013-01-17 08:29 | Thaddy de Koning | Note Added: 0064938 | |
2013-01-17 08:34 | Thaddy de Koning | Note Edited: 0064938 | |
2013-01-17 08:37 | Thaddy de Koning | Note Edited: 0064938 | |
2013-01-17 08:38 | Thaddy de Koning | Note Edited: 0064938 | |
2013-01-17 09:11 | Thaddy de Koning | Note Edited: 0064938 | |
2013-01-17 09:19 | Thaddy de Koning | Note Edited: 0064938 | |
2013-01-17 09:19 | Thaddy de Koning | Note Edited: 0064938 | |
2013-01-17 09:35 | Thaddy de Koning | Note Edited: 0064933 | |
2013-01-17 09:35 | Thaddy de Koning | Note Edited: 0064933 | |
2013-01-17 13:49 | Thaddy de Koning | Note Edited: 0064938 | |
2013-01-17 13:49 | Thaddy de Koning | Note Edited: 0064933 | |
2013-01-17 13:51 | Thaddy de Koning | Note Edited: 0064938 | |
2013-01-17 15:24 | silvioprog | Note Added: 0064953 | |
2013-01-17 15:25 | silvioprog | Note Added: 0064954 | |
2013-01-20 18:08 | silvioprog | Note Added: 0065040 | |
2013-01-21 12:14 | silvioprog | File Added: daemonapp.pp-20120121-0844.patch | |
2013-01-21 12:16 | silvioprog | Note Added: 0065055 | |
2013-01-21 13:54 | Marco van de Voort | Fixed in Revision | => 23480 |
2013-01-21 13:54 | Marco van de Voort | Status | new => resolved |
2013-01-21 13:54 | Marco van de Voort | Fixed in Version | => 2.7.1 |
2013-01-21 13:54 | Marco van de Voort | Resolution | open => fixed |
2013-01-21 13:54 | Marco van de Voort | Assigned To | => Marco van de Voort |
2013-01-21 13:54 | Marco van de Voort | Note Added: 0065057 | |
2013-01-21 14:17 | silvioprog | Status | resolved => closed |
2013-01-21 14:17 | silvioprog | Note Added: 0065058 |