Solved

Boundschecker detects resource leak in Tlist

Posted on 1998-03-02
7
226 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending Gmail through Delphi 3 108
Process Javascript errors with Delphi TWebBrowser 1 132
Comparing dates in Delphi. Greater than/ Less than 3 152
Delphi Form ownership 4 89
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 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