Re: Solve memory problems [message #64741 is a reply to message #64679] |
Thu, 15 January 2009 04:10   |
Guillaume Potdevin
Messages: 1 Registered: January 2009
|
Junior Member |
|
|
Hi!
I followed with great interest this discussion, as I sometimes run into
the same sort of problems, though for other sort of applications.
For reason of commodity, I often use structures. Do structures require a
contiguous space in memory? For example: does
struct = {image1 : BYTARR(4000,5000), image2 : BYTARR(4000,5000) }
require 8 bits * 4000 * 5000 * 2 of continuous space?
And, also the same question in the case of structure arrays: if we have
struct_array = REPLICATE(struct , many_times)
Does struct_array require many_times the space for struct as contiguous
space (in case struct needs a contiguous memory slot)?
But I see the immediate solution here to use arrays of pointers...
Guillaume.
On 14.01.2009 15:53, Jean H. wrote:
> Corinne,
>
> setting var=0 or *ptr_var = 0 will have the same effect on memory.
> Now, let's say you have 10 bands, 4000*5000. If you try to create an
> array like this data = bytarr(4000,5000,10), you might run out of
> memory, or, for the same reason, can not create any other variable (not
> enough contiguous space in memory). With this example, you would need
> about 8 bits * 4000 * 5000 * 10 = 1 600 000 000 bits of contiguous
> memory. Now, if you use points, you can create an array of 10 pointers,
> each holding a band.
> ptr_data = ptrarr(10)
> ptr_data[0] = ptr_new(bytarr(4000,5000)
> ptr_data[1] = ptr_new(bytarr(4000,5000)
> ....
>
> so now, the contiguous memory you need is only 8 bits * 4000 * 5000 =
> 160 000 000 bits.
>
> If band 2 has a different size, no problem:
> ptr_data[2] = ptr_new(bytarr(12,25)
>
> Jean
>
|
|
|