comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: object reference destroy
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: object reference destroy [message #67107 is a reply to message #67105] Mon, 22 June 2009 05:27 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
crane writes:

> I have a container to hold a object, and I need to use this object
> often. In order to avoid memory leakage, i have to destroy the object
> reference after use. But once i destroy the object reference, the
> object in the container is also destroy, because they are pointing to
> the same object. For example:
> ...
> I like to use container to hold object, it is convenience to play with
> objects. can somebody help me through this problem or have another
> idea for alternative.

You might want to have a look at the CatContainer object
in my Catalyst Library code. It reference counts objects
that are added to it by adding a "parent" to the added
object's "people interested in me" list. When the container
is destroyed it takes its name off the "people interested
in me" list and the added object is only destroyed if the
container sees there is no more interest in the object.
That is, the object is destroyed if the container was the
last "person" interested in the object.

Provisions are made in the object to *never* destroy the
object's added to it, if that is what you would prefer, too.

http://www.dfanning.com/programs/catalyst/source/core/catcon tainer__defi
ne.pro

Your objects would simply inherit CatContainer to have this
functionality.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL 7.1.1 Workbench update for Macintosh OS X
Next Topic: Re: AT&T Usenet Netnews Service Shutting Down

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:18:19 PDT 2025

Total time taken to generate the page: 0.00424 seconds