Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Boundschecker detects resource leak in Tlist

Posted on 1998-03-02
7
Medium Priority
?
233 Views
Last Modified: 2011-09-20
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?
0
Comment
Question by:andrewjackson
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 1

Expert Comment

by:bcrotaz
ID: 1359955
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.
0
 

Author Comment

by:andrewjackson
ID: 1359956
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.  
0
 
LVL 1

Expert Comment

by:bcrotaz
ID: 1359957
Yes....it does free the strings.
I've no idea in that case.
I'll step back for someone else.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 5

Expert Comment

by:ronit051397
ID: 1359958
Can you show some code?
0
 
LVL 3

Accepted Solution

by:
williams2 earned 100 total points
ID: 1359959
I think you should try and check boths objects Capacity properties. Delphi normally controls their capacity automatically, but you should be able to set them manually.
If you delete Items, The Items might still exist in memory, but you can remove them by setting

List.Capacity:=List.Count;

..Maybe it works? I haven't got a Boundschecker :-)
0
 

Author Comment

by:andrewjackson
ID: 1359960
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.
0
 
LVL 3

Expert Comment

by:williams2
ID: 1359961
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..
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Loops Section Overview
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question