Board index » delphi » Freeing Objects after you are done?

Freeing Objects after you are done?

Hi,

I see lots of examples for CreateOleObject or CreateObject, but I never
seen a free after the variant is created or when you are done with it. I
know it is a stupid question but should there not some sort of freeing
afterward? Thanks for any help. I have not done much in Ole so please
forgive me for my ignorance.

 

Re:Freeing Objects after you are done?


These objects are reference counted and will be destroyed when they go out
of scope..  However, if you want to implicitly free an object, about the
best you can do is to set the variable to unassigned if you are using
variants and set it to nil if you are using an interface variable..  These
will not free the object, but will reduce the reference count by 1.

Paul

Quote
"Tim Dang" <td...@softwarelabs.com> wrote in message

news:38D920CA.4B27F0C3@softwarelabs.com...
Quote
> Hi,

> I see lots of examples for CreateOleObject or CreateObject, but I never
> seen a free after the variant is created or when you are done with it. I
> know it is a stupid question but should there not some sort of freeing
> afterward? Thanks for any help. I have not done much in Ole so please
> forgive me for my ignorance.

Re:Freeing Objects after you are done?


Thanks. That clears my worries about memory leaks.
Quote
Paul Qualls wrote:
> These objects are reference counted and will be destroyed when they go out
> of scope..  However, if you want to implicitly free an object, about the
> best you can do is to set the variable to unassigned if you are using
> variants and set it to nil if you are using an interface variable..  These
> will not free the object, but will reduce the reference count by 1.

> Paul

> "Tim Dang" <td...@softwarelabs.com> wrote in message
> news:38D920CA.4B27F0C3@softwarelabs.com...
> > Hi,

> > I see lots of examples for CreateOleObject or CreateObject, but I never
> > seen a free after the variant is created or when you are done with it. I
> > know it is a stupid question but should there not some sort of freeing
> > afterward? Thanks for any help. I have not done much in Ole so please
> > forgive me for my ignorance.

Other Threads