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)
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
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
> 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
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
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
: 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
>
>
>
> 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
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
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
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
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
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
> > 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
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
> 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
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
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
- 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
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
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" <
; <[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
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
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
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
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
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
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
28 matches
Mail list logo