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
|
|
|
Re: Array Subscripting Memory Usage (watch out!) [message #32418 is a reply to message #32327] |
Thu, 03 October 2002 03:40  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Andre Kyme wrote:
> 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
Dear Andre
did you have set LONG by compile_option to 64bit Long?
Reimar
--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
|
|
|