I'm trying to store an array of pixel xy indicies for later output to a text file. The number of xy pairs is different for each array element. I'm trying to use pointers to do this with the following code snippet:
xy = ptrarr(npixels, /ALLOC)
for ipixel = 0, npixels - 1 do begin
; much snipped code
indi = where(superMask ne 0, count)
if (count gt 0) then *xy[ipixel] = array_indices(superMask, indi)
; more snipped code
endfor
npixels can range anywhere from fewer than 100 to 200+ and the xy pairs can be a few pair up to a few hundred.
I find that afer a few iterations of the loop (actually ten iterations with the test data i'm using). previously allocated heap pointers are losing their values and become undefined. This would seem to indicate memory allocation problems (the heap pointers are being overwritten by some other portion of the code) , but I'm not sure how to go about troubleshooting it or what I might do to avoid the overwrites. There are no other pointers used anywhere else in the code.
If anyone has a clue as to what the problem might be or a suggestion for a better way to do this, I'd appreciate the help.
Thanks.
|