RE: [DUG]: Destroying Objects

2001-08-26 Thread Dennis Chuah
Ross, You don't have to because Free is a static class procedure defined in TObject, even if you cast the object, it would not have made a difference, except if you reintroduced Free in your class. However, I would like to point out a related issue. The default destructor of TObject (Destroy)

Re: [DUG]: Destroying Objects

2001-08-26 Thread Ben Taylor
i feel the need to comment on this :-) > But you should be sure that any objects you derive override > the virtual destructor Destroy so they'll get called > for your objects as well unless i misunderstand what you're saying, that's not quite right.. if i do: constructor TmyPanel.Create(AOwne

Re: [DUG]: Destroying Objects

2001-08-26 Thread Nello Sestini
earlier i wrote ... > destructor Destroy() in TObject (the base class of every > object) is virtual.Free calls this destructor - so any > derived class overrides will get called with the cast you > describe. this should have read ... derived class overrides will get called withOUT the cast

Re: [DUG]: Destroying Objects

2001-08-26 Thread Nello Sestini
> A simple yes/no question. > > Should I cast an object to it's defined type before I Free it? > ie. MyObject(ListBox.Items.Objects[0]).Free >or simply ListBox.Items.Objects[0].Free will do? No. * (Optional non yes/no portion) destructor Destroy() in TObject (the base class of every ob

Re: [DUG]: Destroying Objects

2001-07-19 Thread jnorth
No different JED >However, if I define the objects as 'class(TObject)', rather than just 'class', >is this any different? ** This email and any files transmitted with it are confidential and intended solely for the use of th

Re: [DUG]: Destroying Objects

2001-07-19 Thread Ross Levis
Neven MacEwan wrote: > the std answer is NO especially when the object has no owner. Thanks for all the replies! I thought it was a simple Yes/No question. My concern is with simple static objects defined as 'class' which I'm linking to listbox.items.objects. I presume since I'm not defining

RE: [DUG]: Destroying Objects

2001-07-19 Thread Dennis Chuah
: IUnknown; begin Unk := TFoo.Create; end; end. Regards, Dennis. > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Friday, 20 July 2001 03:01 > To: Multiple recipients of list delphi > Subject: Re: [DUG]: Destroying Objects > > >

Re: [DUG]: Destroying Objects

2001-07-19 Thread Chrissy R
> If you don't feel like freeing objects, then program in Java or C# (D-flat), > or use interfaces (be careful how you reference the interface). I read about this once. I understood the theory but the practical side of it went over my head. Any chance of a snippet of fully working code that dem

RE: [DUG]: Destroying Objects

2001-07-18 Thread Dennis Chuah
Ross, Simple rule - if you create the object, make sure you free it (in the right place and in the right order). Exceptions to the rule: 1. TComponent can be freed by its owner - but in general I clean that up anyway (make sure you Free it before you free the owner). 2. TCollectionItem obje

Re: [DUG]: Destroying Objects

2001-07-18 Thread Neven MacEwan
Suppose the answer is "You can do it yourself or rely on Microsoft - you choose" Neven - Original Message - From: "Andreas Toth" <[EMAIL PROTECTED]> To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]> Sent: Thursday, 19 July 2001 17

RE: [DUG]: Destroying Objects

2001-07-18 Thread Andreas Toth
IL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of [EMAIL PROTECTED] Sent: Thursday, 19 July 2001 16:03 To: Multiple recipients of list delphi Subject: RE: [DUG]: Destroying Objects Win 95 doesn't but in my experience NT and 2000 do. 2000 is better than NT. JED >From bitter experienc

RE: [DUG]: Destroying Objects

2001-07-18 Thread jnorth
Win 95 doesn't but in my experience NT and 2000 do. 2000 is better than NT. JED >From bitter experience with W95 I am certain that Windows does not clean up ** This email and any files transmitted with it are confidential

RE: [DUG]: Destroying Objects

2001-07-18 Thread Stephen Bertram
ted I believe. Stephen -Original Message- From: Steve Aish [mailto:[EMAIL PROTECTED]] Sent: Thursday, 19 July 2001 2:53 p.m. To: Multiple recipients of list delphi Subject: RE: [DUG]: Destroying Objects IME Windows 9x and Windows 2000 do not free all resources when an application

Re: [DUG]: Destroying Objects

2001-07-18 Thread Chrissy R
> > These are two totally different questions. I would hope that the answer > > to the first is "yes" and would imagine that the answer to the second is > > "sometimes - it depends on circumstances". > > > > Please tell me if I am wrong. > > I just went back and reread the original question and

RE: [DUG]: Destroying Objects

2001-07-18 Thread Steve Aish
s an issue. Steve -Original Message- From: Chrissy R [mailto:[EMAIL PROTECTED]] Sent: Thursday, 19 July 2001 14:35 To: Multiple recipients of list delphi Subject: Re: [DUG]: Destroying Objects When I read the original question I read it was asking "When the application closes is all al

Re: [DUG]: Destroying Objects

2001-07-18 Thread Nello Sestini
> These are two totally different questions. I would hope that the answer > to the first is "yes" and would imagine that the answer to the second is > "sometimes - it depends on circumstances". > > Please tell me if I am wrong. i just went back and reread the original question and see (now) that

Re: [DUG]: Destroying Objects

2001-07-18 Thread Nello Sestini
t: Thursday, July 19, 2001 9:33 AM Subject: RE: [DUG]: Destroying Objects > In actual fact all "resources" are supposed to be freed with NT4 and above > when an application exits (One does assume this also applies to when it > crashes!!). In the case of Win9x this is also

Re: [DUG]: Destroying Objects

2001-07-18 Thread Neven MacEwan
Ross I'm glad that my first impresion was correct - I was going to leap in an give you the std answer ie NO especially when the object has no owner but then i read your question more carefully 'application exits in the normal way' then the feeing of memory is in the control of the OS so the anwse

Re: [DUG]: Destroying Objects

2001-07-18 Thread Chrissy R
- Original Message - From: Alex Kouznetsov <[EMAIL PROTECTED]> To: Multiple recipients of list delphi <[EMAIL PROTECTED]> Sent: Thursday, July 19, 2001 2:09 PM Subject: Re: [DUG]: Destroying Objects > I have had an impression that with latest versions of Windows, when an > appl

Re: [DUG]: Destroying Objects

2001-07-18 Thread Nello Sestini
ake your user any happier. -ns - Original Message - From: "Alex Kouznetsov" <[EMAIL PROTECTED]> To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]> Sent: Thursday, July 19, 2001 9:09 AM Subject: Re: [DUG]: Destroying Objects > I have had

RE: [DUG]: Destroying Objects

2001-07-18 Thread Myles Penlington
ltiple recipients of list delphi Subject: Re: [DUG]: Destroying Objects I have had an impression that with latest versions of Windows, when an application exits, absolutelly all the memory it has allocated is freed by OS. Alex - Original Message - From: "Sergei Stenkov" <

Re: [DUG]: Destroying Objects

2001-07-18 Thread Alex Kouznetsov
; <[EMAIL PROTECTED]> Sent: Thursday, 19 July 2001 10:36 Subject: RE: [DUG]: Destroying Objects > Ross, > > > When an application exits in the normal way, does it automatically > > destroy all objects created at runtime? > > No. You'll need to take care of the

RE: [DUG]: Destroying Objects

2001-07-18 Thread Alan Rose
tiple recipients of list delphi Subject: RE: [DUG]: Destroying Objects Ross, > When an application exits in the normal way, does it automatically > destroy all objects created at runtime? No. You'll need to take care of them var Obj: TObject; begin Obj := TObject.Create; try

RE: [DUG]: Destroying Objects

2001-07-18 Thread Patrick Dunford
Doesn't the owner destroy all components it owns? Even ones you create yourself? > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On > Behalf Of James Low > Sent: Thursday, 19 July 2001 12:34 > To: Multiple recipients of list delphi

Re: [DUG]: Destroying Objects

2001-07-18 Thread Nello Sestini
It would be nice to answer with a simple rule like "if you create it you must destroy it" But it doesn't work like that. For example, TComponent objects explicitly created in your program are automatically destroyed by their owner's destructor - so you don't generally destroy them (and in fact c

RE: [DUG]: Destroying Objects

2001-07-18 Thread Myles Penlington
The simple answer is NO. When using the Visual (eg TControl and upwards) framework that Delphi provides the answer is that the owner of an object (not the parent) is responsible for the objects destruction. Note that in the parent hierarchy, the parent is responsible for getting it's child compo

RE: [DUG]: Destroying Objects

2001-07-18 Thread Sergei Stenkov
Ross, > When an application exits in the normal way, does it automatically > destroy all objects created at runtime? No. You'll need to take care of them var Obj: TObject; begin Obj := TObject.Create; try // do what you need finally Obj.Free; end; end; Cheers, Sergei Stenko

RE: [DUG]: Destroying Objects

2001-07-18 Thread James Low
I think (with few if any exceptions) the rule is that if you programatically create the object, you destroy it. Visible components are destroyed by their owner (unless you have created them (I think)). -Original Message- From: Ross Levis [mailto:[EMAIL PROTECTED]] Sent: 19 July 2001 12:26