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

Home » Public Forums » archive » IDL 8.0 garbage collector issue.
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
IDL 8.0 garbage collector issue. [message #72995] Wed, 20 October 2010 05:47
Bubba is currently offline  Bubba
Messages: 3
Registered: October 2010
Junior Member
I have found something that doesn't seem quite right to me with
regards to the IDL 8.0 garbage collector.

If you have a function that returns a pointer array and you try to
tuck that call into another function call (n_elements for instance)
the pointer gets freed before the second function call completes.
Here is an example program that I wrote to show my problem...

function createPointerArray
compile_opt idl2, logical_predicate

data = ptrarr(3)
data[0] = ptr_new(indgen(10))
data[1] = ptr_new(indgen(10))
data[2] = ptr_new(indgen(10))

return, data
end

pro testGarbageCollector
compile_opt idl2, logical_predicate

; The return from createPointerArray gets destroyed before the
n_elements call is complete
print, n_elements(*(createPointerArray())[0]) ; Prints 0

data = createPointerArray()

print, n_elements(*data[0]) ; Prints 10
end

Am I missing something? Is this expected behavior? It seems to me
that you should be able to do this. It would just be extra unneeded
code to store the return into a variable just to be able to access
it. I use code like this a lot and I can't afford to update it
everywhere.

Please help!
Thanks
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Error Handling Change in IDL 8
Next Topic: Python symposium

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

Current Time: Wed Oct 08 09:20:48 PDT 2025

Total time taken to generate the page: 0.00494 seconds