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

Home » Public Forums » archive » strings and memory usage
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
strings and memory usage [message #55456] Wed, 22 August 2007 11:54
Conor is currently offline  Conor
Messages: 138
Registered: February 2007
Senior Member
Does anyone know how IDL stores strings? I'm creating some very large
string arrays and running out of memory when I shouldn't. So, for the
following example I'm using the linux command 'top' to keep track of
memory usage on a per-process basis. In the beginning, IDL is using
59 megabytes. Then, I create a string array with 5 million elements
like this:

test = strarr(5000000) + 'asdf'

Now I have a string array with 5,000,000 elements, each with 4
characters in it. According to top idl is now consuming 177
megabytes! That means that each string takes up an average of 23
bytes! To make matters worse, when I delete test (delvar,test) IDL
drops back down to 120 megabytes!

What in the world is going on? Naievly, I would expect a string array
with strings 4 characters long to take up an absolute maximum of 8
bytes per element (4 bytes for the characters, 2 bytes for the length,
and maybe two bytes for pointers). Why is it taking up 23 bytes???
Am I just confused about something? Also, why doesn't the memory
usage drop back down to it's original value? I did notice one thing.
When I then created more large variables, the memory usage didn't
increase right away, so maybe IDL is clearing the memory but not
releasing it to the operating system. Still, I find these problems
very troubling. Is there something very wrong with the string arrays
in IDL, or am I just being silly?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Fill intersection of two contours
Next Topic: Passing variables

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

Current Time: Sat Oct 11 08:51:59 PDT 2025

Total time taken to generate the page: 0.80051 seconds