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

Home » Public Forums » archive » Destroying objects
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: Destroying objects [message #82760 is a reply to message #37981] Fri, 18 January 2013 09:12 Go to previous message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Friday, January 18, 2013 9:33:43 AM UTC-7, Helder wrote:
> Hi,
>
> as usual I'm do things wrong believing I'm not until I wake-up.
>
> So here's the thing. I'm using a structure to describe some objects. In my case these are regions of interest. Within this structure I have real objects. So that my structure looks something like this:
>
>
>
> MyStruct = {ROI_Structure, a:ID_Nr, b:SomeOtherParameter, c:Obj_new()}
>
> I then fill in MyStruct.c by doing something like this:
>
> XROI, MyImage, REGIONS_OUT = XROI_ObjRef
>
> MyStruct.c = XROI_ObjRef
>
>
>
> The thing is that I then replicate this structure when I add new ROIs.
>
> So I end up with say 10 {ROI_Structure} where for each element I did something like this:
>
> for i=0,9 do MyStruct[i].c = XROI_ObjRef[i]
>
>
>
> If and when somewhere later in the program I want to delete object number 5... do I have to take care of using
>
> Obj_destroy, MyStruct[5].c
>
>
>
> Is there no alternative?
>
> Thing is, in this structure I have many pointers and objects...
>
>
>
> I'm I wrong in saying that I have to do the good-boy bookkeeping and free/destroy for each deleted structure element all pointers and objects?
>
>
>
> Thanks,
>
> Helder

Hi Helder,

If you are using IDL 8.0 or later, then as long as you don't have any "circular" references, the automatic garbage collection should free all of the pointers & objects once the variables go out of scope.

However, if you have circular references, where one object references another object, and that other object somehow references the first one, then the garbage collector won't be able to decrement the reference counts to zero.

Another possibility is to use HEAP_GC, which is a big hammer...

Cheers,
Chris
ExelisVIS
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Destroying objects
Next Topic: Re: shading/outlining on surface plot

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

Current Time: Sat Oct 11 09:25:31 PDT 2025

Total time taken to generate the page: 0.64157 seconds