object reference destroy [message #67110] |
Mon, 22 June 2009 02:53 |
dosfun
Messages: 14 Registered: February 2009
|
Junior Member |
|
|
hi, people
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:
; put a object into the container
container = obj_new('idl_container')
obj = obj_new('myclass')
container->add, obj
; get the object for the first time
objref _1= container->get(/all)
....
; destroy the object reference for the first time. (memory reason)
obj_destroy, objref_1
; need to get the object from the container second time
objref_2= container->get(/all)
; but objref_2 is not a valid object anymore, because i destroy the
object in the previous section.
IDL> print, obj_valid(objref_2)
0
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. thanks.
|
|
|