Strange memory consumption? [message #13159] |
Fri, 16 October 1998 00:00 |
Alex Schuster
Messages: 124 Registered: February 1997
|
Senior Member |
|
|
I just noticed this:
IDL> a = bindgen( 1000, 1000, 10 )
IDL> help, /mem
heap memory used: 10183855, max: 10183883, gets: 188,
frees: 61
IDL> a[*] = 1b
IDL> help, /mem
heap memory used: 10183906, max: 50183966, gets: 192,
frees: 63
I create a 10 MB array, and initialize it, using the [*] notation. It
seems that the asterisk is substituted by a lindgen(10000000L), which
takes another 40 MB! And I always believed this method was very
efficient.
This workaround does it better:
IDL> a = bindgen( 1000, 1000, 10 )
IDL> help, /mem
heap memory used: 10183855, max: 10183883, gets: 188,
frees: 61
IDL> a = temporary(a) * 0b + 1b
IDL> help, /mem
heap memory used: 10183920, max: 10183948, gets: 191,
frees: 62
Voila, no additional memory needed. This is also a lot faster.
** Structure !VERSION, 5 tags, length=40:
ARCH STRING 'sparc'
OS STRING 'sunos'
OS_FAMILY STRING 'unix'
RELEASE STRING '5.1'
BUILD_DATE STRING 'Apr 13 1998'
Alex
--
Alex Schuster Wonko@weird.cologne.de PGP Key available
alex@pet.mpin-koeln.mpg.de
|
|
|