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

Home » Public Forums » archive » Re: Question about the object lifecycle
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Question about the object lifecycle [message #68657] Sat, 07 November 2009 15:55
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
M. Katz writes:

> Within complex graphic objects, I often add objects to a main model
> like this
>
> self.oModel = obj_new('IDLgrModel')
> self.oModel -> Add, obj_new('IDLgrPolygon', . . .)
>
> I don't keep an explicit reference to the IDLgrPolygon object in this
> case because I don't need it.
>
> My question is: What happens to the IDLgrPolygon once I destroy the
> parent object? My Cleanup method explicity destroys the self.oModel.
> So what becomes of the orphaned IDLgrPolygon? Will it go into heap
> limbo and ultimately be recycled? Or will it take up space until the
> IDL session is reset? I can see from a quick test using HELP that once
> the IDLgrModel is destroyed, the reference to the child object becomes
> <ObjHeapVar2>, like that.
>
> As a best-practice, should I be keeping the references to every object
> I create in this way, so I can explicitly destroy them in the Cleanup
> method?

A model object is a subclassed IDL_Container object, so any
thing you add to the model is destroyed when the model is
destroyed. So no reason to keep references to objects you
add directly to a model. It is the other objects (e.g, font objects
that you add to text objects that you add to a model object
you have to watch out for). Those can bite you. Always
run your program, exit, and then type Help, /Heap before
you give your program to your boss. You will save yourself
a LOT of embarrassment. Take it from me. :-)

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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Question about the object lifecycle
Next Topic: HDF5 Output in IDL

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

Current Time: Sat Oct 11 14:19:33 PDT 2025

Total time taken to generate the page: 0.16570 seconds