Re: question on destroying objarr's [message #62060] |
Tue, 19 August 2008 13:07 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Jean H. writes:
> loop through them...
> for i=0,2 do obj_destroy, myObjArr[i]
Oh, for goodness sake. Totally unnecessary!
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.")
|
|
|
Re: question on destroying objarr's [message #62062 is a reply to message #62060] |
Tue, 19 August 2008 12:12  |
Jean H.
Messages: 472 Registered: July 2006
|
Senior Member |
|
|
cgoethel@igpp.ucla.edu wrote:
> Hello,
>
> Does anyone have a simple example of how to create, populate, and
> destroy an objarr? I can create and populate (in a clumsy way) but
> then I am cannot get rid of it using OBJ_DESTROY.
>
> Thanks! Cindy
>
> EX:
>
> myObjArr=OBJARR(3)
> myObjArr[0]=someObj
> OBJ_DESTROY, myObjArr
>
> help, myObjArr
> MYOBJARR OBJREF = Array[3] (it's still there - why?)
loop through them...
for i=0,2 do obj_destroy, myObjArr[i]
Jean
|
|
|
Re: question on destroying objarr's [message #62063 is a reply to message #62062] |
Tue, 19 August 2008 12:02  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> Well, it's still there in the sense that variable myObjArr
> is still listed as having been previously defined as
> *something* in the IDL session. But all the objects in
> that object array are null objects. You can't use them
> for anything. They don't point to anything. They are not
> taking up any space on the heap. Etc.
>
> In other words, you are in great shape! :-)
Here is another way of looking at this:
IDL> myObjArr=OBJARR(3)
IDL> myObjArr[0]=Obj_New('idlanroi')
IDL> Help, /HEAP
Heap Variables:
# Pointer: 0
# Object : 1
<ObjHeapVar21> STRUCT = -> IDLANROI Array[1]
IDL> OBJ_DESTROY, myObjArr
IDL> Help, /HEAP
Heap Variables:
# Pointer: 0
# Object : 0
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.")
|
|
|
Re: question on destroying objarr's [message #62064 is a reply to message #62063] |
Tue, 19 August 2008 11:57  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
cgoethel@igpp.ucla.edu writes:
> Does anyone have a simple example of how to create, populate, and
> destroy an objarr? I can create and populate (in a clumsy way) but
> then I am cannot get rid of it using OBJ_DESTROY.
>
> Thanks! Cindy
>
> EX:
>
> myObjArr=OBJARR(3)
> myObjArr[0]=someObj
> OBJ_DESTROY, myObjArr
>
> help, myObjArr
> MYOBJARR OBJREF = Array[3] (it's still there - why?)
Well, it's still there in the sense that variable myObjArr
is still listed as having been previously defined as
*something* in the IDL session. But all the objects in
that object array are null objects. You can't use them
for anything. They don't point to anything. They are not
taking up any space on the heap. Etc.
In other words, you are in great shape! :-)
If you want to get rid of it entirely, you will have to
do something like this:
IDL> myObjArr=OBJARR(3)
IDL> myObjArr[0]=Obj_New('idlanroi')
IDL> OBJ_DESTROY, myObjArr
IDL> Undefine, myObjArr
IDL> Help, myObjArr
MYOBJARR UNDEFINED = <Undefined>
You can find UNDEFINE here:
http://www.dfanning.com/programs/undefine.pro
Just don't undefine before you destroy!!!
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.")
|
|
|