Article View: borland.public.delphi.winforms.controls.using
Article #150Re: Component.Dispose(bool) problem
From: Peter Morris [Droopy eyes softwa...
Date: Wed, 05 Jul 2006 13:06
Date: Wed, 05 Jul 2006 13:06
39 lines
2078 bytes
2078 bytes
Hi Chee Wee
These are the exact steps, honest :-)
1) Create a new Delphi WinForm app (dotnet)
2) Drop any non-visual component onto the form
3) Put a break line on the first line of the Dispose method
You will see that "components" is always null, so components.Dispose is not
called. Therefore MyComponent.Dispose is not called until garbage
collected, at which point I cannot rely upon my references being valid for
me to clean them up.
public class MyComponent: System.ComponentModel.Component
{
protected override void Dispose(bool disposing)
{
if (disposing)
//Do anything here, but it will never get called!
}
}
It's exactly the same in VS2003 but seems to be fixed in VS2005.
Unfortunately it means that my ECO components are leaving UndoBlocks lying
around + taking up memory because the component is never disposed.
--
Pete
====
Audio compression components, DIB graphics controls, ECO extensions,
FastStrings
http://www.droopyeyes.com
My blog
http://blogs.slcdug.org/petermorris/
Technical Details
Message-ID:
<44abb93f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<44ab6a34$1@newsgroups.borland.com> <il0na258mjappn07usvin5sphleob7ege9@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1eff29,4d562b5bfdb92132 X-Google-Attributes: gid1eff29,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Peter Morris [Droopy eyes software]" <pete@NO_droopyeyes_SPAM.com> Newsgroups: borland.public.delphi.winforms.controls.using References: <44ab6a34$1@newsgroups.borland.com> <il0na258mjappn07usvin5sphleob7ege9@4ax.com> Subject: Re: Component.Dispose(bool) problem Date: Wed, 5 Jul 2006 14:06:04 +0100 Lines: 41 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 82.46.138.4 Message-ID: <44abb93f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1152104767 82.46.138.4 (5 Jul 2006 06:06:07 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail