Link to home
Start Free TrialLog in
Avatar of andrewjackson
andrewjackson

asked on

Boundschecker detects resource leak in Tlist

I'm using Boundchecker 5.03 to debug applications that were created in Delphi 3.02. I've noticed that Boundschecker reports resource leaks every time my code creates a TList or TStringList object.

I either call TList.Create in the constructor for an object and call the Free method in the corresponding destructor, or I encapsulate the 'Create' and 'Free' methods in a try..finally block.  I can't see where I'm going wrong and create /destroy plenty of other objects dynamically without any resource leaks.  The size of each resource leak varies which I also think is odd.

Can anyone help?
Avatar of bcrotaz
bcrotaz

When you free the list, is it empty?
If you delete an object or free the list, you don't free the listed objects.  You'll need to iterate through the list and free them first.
Avatar of andrewjackson

ASKER

Thanks for you reply but I do free all the listed objects.  Anyhow, even if I didn't this would show as resource leaks where I created the listed objects, and be in no way associated with any particular TList object. In the case of a TStringList, I've assumed that Delphi handles deletion of all listed strings even though resource leaks are still reported.  
Yes....it does free the strings.
I've no idea in that case.
I'll step back for someone else.
Can you show some code?
ASKER CERTIFIED SOLUTION
Avatar of williams2
williams2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've spotted a similar question to mine posted on the

borland.public.delphi.objectpascal

newsgroup.  The problem has been traced to a bug in Boundschecker and acknowledged by Numega so the reported resource leaks do not actually exist.  Thanks all the same for all the suggestions that have been posted.
Now you have found the bug, I've been working on an alternative TList component build with a relative doublechained listindex. It works similar, but is a bit faster in some ways.
Now you have graded me, you can have it if you like..