X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 08 Jun 2006 02:26 PM by  anon
storing variable
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
08 Jun 2006 02:26 PM
    hello if i create variable like this a=5 where is it storing ? in heap ? or in heap storing only data, which created by PTR_NEW ? thanks

    Deleted User



    New Member


    Posts:
    New Member


    --
    08 Jun 2006 02:26 PM
    The heap stores most, if not all, variable assignments. However, it only "garbage collects" memory that does not have a pointer pointing to it. Thus: a = findgen(1000000) will put 4MM new bytes of memory in the heap. A subsequent: a = 0.0 will free 3,999,999 bytes of that memory from the heap. However: a = ptr_new(findgen(1000000)) also puts 4MM new bytes of memory in the heap. The subsequent: a = 0.0 does not free ANY memory. Now the memory has 4000001 bytes devoted to the activity of this variable named 'a'. You have to explicitly call: ptr_free, a before you reassign 'a', if you want to keep your heap memory "leak"-free. James Jones
    You are not authorized to post a reply.