circular reference detection, posible?

delphi package - automated exception handling

circular reference detection, posible?

Postby santiago » Mon Mar 11, 2019 9:44 pm

Hello madschi,

it is well known that circular references between interface objects cause memory leaks.

E.g:

Obj1 -> references Obj2
Obj2 -> references Obj1

Obj1, and Obj2 are interface objects, they will be released once their reference count reaches 0. This will never happen in this case, due to the circular reference.
As a consequence Obj1 and Obj2 are never freed.

If Obj1 and Obj2 hold references to many other objects, which themselves reference other objects you will just get a massive leak report. Finding the two objects which are causing the leak becomes a nightmare...

Would it be possible for you to detect such circular references in madExcept?

You can't imagine how useful that would be for us.... And I imagine for many others as well.

Looking forward to hear your response.

Thanks!
santiago
 
Posts: 49
Joined: Thu May 05, 2016 6:01 pm

Re: circular reference detection, posible?

Postby madshi » Tue Mar 12, 2019 4:50 pm

This could be really difficult. For example, the circular reference could be hidden in some array or even pointer. Not sure if I can find that. Furthermore, in theory there could be a logic which allows and then properly cleans up such circular references, so they don't actually have to be a sign of a problem. I'm afraid if I try to add such a detection logic, it might throw out all sorts of false positives, driving me and madExcept users crazy.

My experience with resource leak detection has generally not been so great. Users come to me all the time, asking me if this or that is really a leak or not, pointing to 3rd party components or even the RTL/VCL itself. It costs me a lot of time. Now if I add something like this, and it ends up causing lots of false positives, that would turn into a support nightmare for me... :(
madshi
Site Admin
 
Posts: 9960
Joined: Sun Mar 21, 2004 5:25 pm

Re: circular reference detection, posible?

Postby santiago » Tue Mar 12, 2019 11:41 pm

Hello madschi,

I completely understand, your concern is very reasonable.
Is there anyway we could implement something like that?
Maybe some sort of user-plugin?

Despite all limitations it would very handy for us to have a list of circular references at a given time.

Thanks!
santiago
 
Posts: 49
Joined: Thu May 05, 2016 6:01 pm

Re: circular reference detection, posible?

Postby madshi » Mon Mar 18, 2019 10:22 am

It's pretty complicated. The problem is that you don't know where the circular reference might be stored. It could be a public or private object variable. Or it could be inside of an array of structure or even part of an allocated memory block. How can you automatically find that? It's not completely impossible, but really hard.
madshi
Site Admin
 
Posts: 9960
Joined: Sun Mar 21, 2004 5:25 pm


Return to madExcept

Who is online

Users browsing this forum: Exabot [Bot] and 7 guests