* * *

Author Topic: HeapTrc - can expected leaks be ignored?  (Read 2584 times)

Remy Lebeau

  • Sr. Member
  • ****
  • Posts: 348
    • Lebeau Software
HeapTrc - can expected leaks be ignored?
« on: April 29, 2016, 07:46:09 pm »
In many 3rd party memory managers, like FastMM, when leak detection is enabled, they provide an option to ignore specific leaks that are intentional in code (Delphi and FastMM have RegisterExpectedMemoryLeak(), MadExcept has HideLeak(), etc).  I just found out about FreePascal's HeapTrc unit, but it does not appear to provide this option.  Have I missed it, or can it be added?
« Last Edit: May 16, 2017, 10:15:04 pm by Remy Lebeau »
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) open source project - Admin, Developer

Remy Lebeau

  • Sr. Member
  • ****
  • Posts: 348
    • Lebeau Software
Re: HeapTrc - can expected leaks be ignored?
« Reply #1 on: May 16, 2017, 10:11:32 pm »
Bump.  Question still applies.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) open source project - Admin, Developer

zeljko

  • Hero Member
  • *****
  • Posts: 938
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: HeapTrc - can expected leaks be ignored?
« Reply #2 on: May 16, 2017, 10:15:11 pm »
There's no such option for heaptrc afaik.

wp

  • Hero Member
  • *****
  • Posts: 3949
Re: HeapTrc - can expected leaks be ignored?
« Reply #3 on: May 16, 2017, 11:14:35 pm »
Just curious: What would be a reason for an intended memory leak?
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Thaddy

  • Hero Member
  • *****
  • Posts: 4745
Re: HeapTrc - can expected leaks be ignored?
« Reply #4 on: May 17, 2017, 03:26:32 am »
Well, that has to do with carpets, floors and blankets.

Say you are fully aware that the OS will return all memory after a program is closed anyway, why would you hunt down that leak that obviously is there but you can not find?
Or you found, but YOU, a mere programmer, decided is too expensive to solve? Of course you don't consult any colleagues because you don't want to look silly and you are god and god knows best.
You are the god programmer, so you just put a blanket over your head and send it to testing... Testers ignore run-time behavior, they just look at the stability. Sort of...
So you can lift up the carpet and put your leak there. Maybe it goes away... 8-) You do this, of course, just before Christmas so you know you will keep your bonus...
Timing is essential here.

So basically the option is there to remember you that you were a very naughty boy or girl.
That... or you invested money in leaky third-party components that are "brilliant" and your house would collapse if you.... (but that is recursive...)

It is almost never an intended memory leak. It is a known memory leak that you want to ignore. Because everything else seems ok. And hey! it works! O:-)

On a serious note:
If you have multiple leaks it is a real help to hide some of them while you are hunting the others. They may have to do with each other.
[/]
Of course Delphi professional programmers feel obliged to keep it in the production code... :-* At least until February.

Yes, the issue is cyclic. >:(
« Last Edit: May 17, 2017, 04:49:05 am by Thaddy »
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Eugene Loza

  • Hero Member
  • *****
  • Posts: 521
    • My "almost daily" development blog
Re: HeapTrc - can expected leaks be ignored?
« Reply #5 on: May 17, 2017, 05:56:28 am »
(Real Life situation) In my code there is a memory leak I can't track down. And there are 4 (?) other memory leaks, that I can understand and fix. How do I know I've fixed them all? As long as there is one difficult-to-find counted, I still have a memory leak report. If I could ignore it, then I'd be sure I've fixed all the other memory leaks and I've left with only one to fix. Or just forget about one and be absolutely sure there are no more.
Yes, that looks like a rare and a dirty case, but might help somebody.
Lazarus 1.9 + FPC 3.1.1 Debian Jessie 64 bit.

My Free and Open Source games in Lazarus/FreePascal/CastleGameEngine:
https://decoherence.itch.io/
(and some ancient games in Turbo Pascal too)
Sources are here: https://github.com/eugeneloza?tab=repositories

wp

  • Hero Member
  • *****
  • Posts: 3949
Re: HeapTrc - can expected leaks be ignored?
« Reply #6 on: May 17, 2017, 07:11:45 am »
It is almost never an intended memory leak.
This wording referred to Remy's formulation "leaks that are intentional in code".
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Remy Lebeau

  • Sr. Member
  • ****
  • Posts: 348
    • Lebeau Software
Re: HeapTrc - can expected leaks be ignored?
« Reply #7 on: May 23, 2017, 09:21:25 pm »
It is almost never an intended memory leak.
This wording referred to Remy's formulation "leaks that are intentional in code".

There are 3 intentional memory leaks in Indy.  A few global objects that are created during unit initialization but are not freed by default during unit finalization (though there is a compiler define provided to turn on that behavior, but it is not defined by default).  This is mainly due to issues related to bad unit finalization order in some situations, causing runtime errors trying to access objects that no longer exist, so they are leaked by default to prevent such errors.  In Delphi, Indy registers these leaks with the memory manager so they are not reported in leak reports.  It would be nice to do the same in FreePascal.
« Last Edit: May 23, 2017, 09:23:00 pm by Remy Lebeau »
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) open source project - Admin, Developer

taazz

  • Hero Member
  • *****
  • Posts: 4481
Re: HeapTrc - can expected leaks be ignored?
« Reply #8 on: June 03, 2017, 06:08:35 am »
just a heads up, I think that the latest fastmm4 can be used from fpc/lazarus and supports linux, windows and MacOS. Now if only I could find a leak viewer for fastmm....
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Leledumbo

  • Hero Member
  • *****
  • Posts: 7741
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: HeapTrc - can expected leaks be ignored?
« Reply #9 on: June 03, 2017, 06:26:24 pm »
just a heads up, I think that the latest fastmm4 can be used from fpc/lazarus and supports linux, windows and MacOS. Now if only I could find a leak viewer for fastmm....
Nope, I just cloned the repo and made some fixes instead. Now it's working under linux (both i386 and x86_64), however my pull request is waiting to be merged :)
And no, it doesn't compile for fpc windows target. No idea about osx.
« Last Edit: June 03, 2017, 07:33:53 pm by Leledumbo »

taazz

  • Hero Member
  • *****
  • Posts: 4481
Re: HeapTrc - can expected leaks be ignored?
« Reply #10 on: June 04, 2017, 01:27:16 am »
just a heads up, I think that the latest fastmm4 can be used from fpc/lazarus and supports linux, windows and MacOS. Now if only I could find a leak viewer for fastmm....
Nope, I just cloned the repo and made some fixes instead. Now it's working under linux (both i386 and x86_64), however my pull request is waiting to be merged :)
And no, it doesn't compile for fpc windows target. No idea about osx.
I create a fastmm package and compiled it on windows with out problems (laz 1.4.4) I haven't spend any time using it though.  Its on my to do list after my current clean up.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Leledumbo

  • Hero Member
  • *****
  • Posts: 7741
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: HeapTrc - can expected leaks be ignored?
« Reply #11 on: June 04, 2017, 09:30:11 pm »
I create a fastmm package and compiled it on windows with out problems (laz 1.4.4) I haven't spend any time using it though.  Its on my to do list after my current clean up.
Well... it's a continuously developed unit. It may used to be working, but at least the latest commit doesn't work. The author does admit he doesn't work on FPC compatibility part, it's all 3rd party contribution. Hence, his changes may break the compatibility anytime.

taazz

  • Hero Member
  • *****
  • Posts: 4481
Re: HeapTrc - can expected leaks be ignored?
« Reply #12 on: June 04, 2017, 10:18:17 pm »
I create a fastmm package and compiled it on windows with out problems (laz 1.4.4) I haven't spend any time using it though.  Its on my to do list after my current clean up.
Well... it's a continuously developed unit. It may used to be working, but at least the latest commit doesn't work. The author does admit he doesn't work on FPC compatibility part, it's all 3rd party contribution. Hence, his changes may break the compatibility anytime.
There are a couple of differences
  1) I used the sf repo ee https://sourceforge.net/projects/fastmm/
  2) I use laza1.4.4 aka fpc 2.6.4 not 3.
In any case it shouldn't be to much trouble to correct it.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus