Recent

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

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1311
    • 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) - Admin, Developer (Support forum)

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1311
    • 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) - Admin, Developer (Support forum)

zeljko

  • Hero Member
  • *****
  • Posts: 1591
    • 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: 11830
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?

Thaddy

  • Hero Member
  • *****
  • Posts: 14166
  • Probably until I exterminate Putin.
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 »
Specialize a type, not a var.

Eugene Loza

  • Hero Member
  • *****
  • Posts: 656
    • My games in Pascal
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.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

wp

  • Hero Member
  • *****
  • Posts: 11830
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".

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1311
    • 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) - Admin, Developer (Support forum)

taazz

  • Hero Member
  • *****
  • Posts: 5368
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: 8744
  • 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: 5368
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: 8744
  • 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: 5368
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

 

TinyPortal © 2005-2018