Solved

Boundschecker detects resource leak in Tlist

Posted on 1998-03-02
7
228 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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