Re: Array Subscripting Memory Usage (watch out!) [message #32327] |
Wed, 02 October 2002 16:23  |
Andre Kyme
Messages: 19 Registered: September 2001
|
Junior Member |
|
|
Dick Jackson wrote:
> Hi all,
>
> This may be old news to some of you, but it surprised me and a couple of
> colleagues, and I couldn't find any discussion of it on this group, so
> I'll share it around.
>
> I was surprised to find how much memory is used during access to a
> subset of an array. I ran this, which makes a 1000x1000 array, and
> accesses a subset of it using an array of subscripts:
>
> a = bindgen(1000, 1000)
> subscripts = Long(RandomU(seed, 500)*1000)
> baseMem = (memory())[0]
> help, a[subscripts, *]
> highWaterMem = (memory())[3]
> Print, 'Memory used during access: ', highWaterMem-baseMem
>
> IDL> .GO
> <Expression> BYTE = Array[500, 1000]
> Memory used during access: 2500076
>
> The array being extracted is 0.5 million bytes, but it took 2.5 million
> bytes to do it! I'm guessing that there's a Long array being made behind
> the scenes that contains the indices of the elements I'm going to get
> back.
Dick, I ran your little program on IDL5.5 (Solaris 9) and got the following
output:
<Expression> BYTE = Array[500, 1000]
Memory used during access: 4500128
Yikes, I get 9N bytes needed to extract an N byte array!
Andre
|
|
|