Re: Container/Holder Destruction [message #45617 is a reply to message #45616] |
Mon, 19 September 2005 04:22  |
Antonio Santiago
Messages: 201 Registered: February 2004
|
Senior Member |
|
|
IDLmastertobe wrote:
> Hi, I am objects in my code and trying to destroy them after using to avoid
> memory leaks. I have created many objects and to destroy them, I created
> another holder object using IDLgrContainer, I am just wondering if I
> destroy this holder object, would all the objects I added into this holder
> object be destroyed as well? or I need to destroy everything one by one?
> Thanks.
>
Your question has a simple response, make a test:
PRO test
o1 = OBJ_NEW('IDLgrImage')
o2 = OBJ_NEW('IDLgrImage')
o3 = OBJ_NEW('IDLgrImage')
o4 = OBJ_NEW('IDLgrImage')
c = OBJ_NEW('IDL_Container')
c->Add, [o1, o2, o3, o4]
print, 'Num object = ',c->Count()
HELP, /HEAP
OBJ_DESTROY, c
print, 'Container destroyed'
HELP, /HEAP
END
When you destroys an IDL_Container it executes the 'cleanup' method of
the holded objects.
Some is interesting destroy the container but not the objects inside it
(because another object has the same reference). Then is needes execute:
c->Remove, /ALL
OBJ_DESTROY, c
Bye.
PD: Take a look at my web page (this is not spam :) ) i have some litlle
clases for IDL that can simplify the OO programer life in IDL.
--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
GRAHI - Grup de Recerca Aplicada en Hidrometeorologia
Universitat Polit�cnica de Catalunya
-----------------------------------------------------
|
|
|