Re: Memory allocation problems [message #58076 is a reply to message #58075] |
Wed, 16 January 2008 06:55  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Anne writes:
> I'm trying to create a pyramid of smaller images from a very large
> initial image and have run into a strange memory allocation problem.
> My assumption is that I'm messing up somehow but I can't see where.
>
> My initial image, im, is a [3,9000,8000] array and I'm trying to
> assign a subset of the image to an [8192,8192] array (powers of 2 are
> necessary for my application)
>
> The bit of code that's causing me trouble is
>>> tileIm=bytarr(3,tile*scale,tile*scale) (scale=16 so tileim is [3,8192,8192])
>>> imsize = size(im)
>>> ydim = imSize[3] - low_y
>>> tileIm[*,*,0:ydim-1] = im[0:2,low_x:high_x,low_y:imSize[3]-1]
>
> (low_x = 0, high_x = 819, 1ow_y = 0, high_y = 8191 for this particular
> iteration)
>
> This gives me the message
> % Unable to allocate memory: to make array.
>
> But I do have memory available on my system (2Gb in total available)
>
> I can allocate the segment to a new variable, ie
>>> test = im[0:2,low_x:high_x,low_y:imSize[3]-1]
> but surely that requires even more memory?
>
> If I then try
> IDL> tileIm[*,*,0:ydim-1] = test
> % Unable to allocate memory: to make array.
>
> I can't use temporary as I need the original image im for subsequent
> iterations
> What am I doing wrong. Is there a work around?
You are running into the ol' "it takes a TON of memory to
subscript an array" problem:
http://www.dfanning.com/misc_tips/submemory.html
You can read the article for some suggestions on how to
approach the problem.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|