comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Array Subscripting Memory Usage (watch out!)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Array Subscripting Memory Usage (watch out!) [message #32378 is a reply to message #32328] Fri, 04 October 2002 13:58 Go to previous messageGo to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Fri, 04 Oct 2002 13:13:14 -0700, Dick Jackson wrote:



>> STRING:
>> .reset
>> s=memory()&x=indgen(20,/string)&e=memory()& print,e[3]-s[0]
>> 748
>> .reset
>> s=memory()&x=indgen(10,/string)&e=memory()& print,e[3]-s[0]
>> 458
>> The difference is 290. How to explain, the string length is 12 of each
>> element. Normally I believe 1 char is 1 byte. So first result should
> be
>> 12 byte * 20 = 240 and the second one 120. The differnce should be
> 120.
>> So I have no explanation why it needs so much more memory. Any ideas?
>
> I think each string would be terminated by a null character, making it
> 13 bytes each, then increase that to 16 because of 4-byte words, but
> that still doesn't match... I give up at this point!

Actually, if you look through export.h, you can see that IDL strings are
not only null-terminated (like C), but also have other information saved
in the IDL_STRING structure, like the length and type of the string. You
typically need 12 bytes just for an empty string! Also of interest in
solving the puzzle:

IDL> print,'*'+indgen(1,/string)+'*'
* 0*

These strings are 12 characters long. That's 25 bytes so far, counting
the terminating null. One more 4-byte word will do it. I'll leave that
one as an exercise for the reader ;)

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Array comparison part 2
Next Topic: how to get time consumed by idl program?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 23:03:34 PDT 2025

Total time taken to generate the page: 0.80057 seconds