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

Home » Public Forums » archive » Re: Memory Cleanup-- Messy structure
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Memory Cleanup-- Messy structure [message #71402 is a reply to message #71400] Wed, 16 June 2010 14:16 Go to previous messageGo to previous message
rogass is currently offline  rogass
Messages: 200
Registered: April 2008
Senior Member
On 16 Jun., 19:50, Ed Hyer <ejh...@gmail.com> wrote:
> OK, here's the sequence:
>
> IDL> STRUCT1=CREATE_STRUCT("PTR1",PTR_NEW());
> IDL> STRUCTALL=REPLICATE(STRUCT1,N)
> IDL> FOR I=0,N-1 DO STRUCTALL.PTR1=PTR_NEW(ALLDATA[*,I])
>
> Then I do what I need to do, and I'm done with it, so:
>
> IDL> UNDEFINE, STRUCTALL
>
> Except this doesn't free the memory, according to HELP,/HEAP.
>
> Since I'm not a real programmer, I still consider pointers to be kinda
> voodoo. Can someone patiently explain how I manually clean up the
> memory in this case?
>
> Thanks,
>
> --Edward H.

Hm, what's going on here. If I would do this on my PC the following
happens:

IDL> help,/heap
Heap Variables:
# Pointer: 0
# Object : 0
IDL> n=10
IDL> s={ptr1:ptr_new()}
IDL> help,/heap
Heap Variables:
# Pointer: 0
# Object : 0
IDL> sall=REPLICATE(S,N)
IDL> help,/heap
Heap Variables:
# Pointer: 0
# Object : 0
IDL> FOR I=0,N-1 DO SALL[i].PTR1=PTR_NEW(dist(i+1))
% Compiled module: DIST.
IDL> help,/heap
Heap Variables:
# Pointer: 10
# Object : 0

<PtrHeapVar1> FLOAT = Array[1]
<PtrHeapVar2> FLOAT = Array[2, 2]
<PtrHeapVar3> FLOAT = Array[3, 3]
<PtrHeapVar4> FLOAT = Array[4, 4]
<PtrHeapVar5> FLOAT = Array[5, 5]
<PtrHeapVar6> FLOAT = Array[6, 6]
<PtrHeapVar7> FLOAT = Array[7, 7]
<PtrHeapVar8> FLOAT = Array[8, 8]
<PtrHeapVar9> FLOAT = Array[9, 9]
<PtrHeapVar10> FLOAT = Array[10, 10]
IDL> undefine,sall
IDL> help,/heap
Heap Variables:
# Pointer: 0
# Object : 0


That's why I very like David's routines - they do always their jobs :)

Your problem might be that you don't correctly reference your pointer
array. You forgot:
STRUCTALL--->[I]<-----
So, maybe you allocate some memory each time in the loop, but then you
always overwrite the pointer(s).

Regards

CR
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Memory Cleanup-- Messy structure
Next Topic: SAVE compress and Gzip

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

Current Time: Fri Oct 10 01:03:33 PDT 2025

Total time taken to generate the page: 0.00489 seconds