X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 20 Oct 2010 10:28 AM by  anon
IDL 8.0 garbage collector issue
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
20 Oct 2010 10:28 AM
    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

    Deleted User



    New Member


    Posts:21
    New Member


    --
    21 Oct 2010 09:11 AM
    Hi Keith, This was a bug in 8.0. It is fixed in the upcoming 8.0.1 patch release (hopefully in the next few weeks). Thanks for taking the time to create a reproduce case. Cheers, Chris ITTVIS
    You are not authorized to post a reply.