Re: Strange memory consumption? [message #13156 is a reply to message #13155] |
Fri, 16 October 1998 00:00  |
Kevin Ivory
Messages: 71 Registered: January 1997
|
Member |
|
|
Alex Schuster wrote:
> 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
Hi Alex,
I wasn't aware of that, but I would do it differently in the first place.
If you know you want to initialize an array with a constant, there are
much better ways of doing so. First of all, use bytarr instead of
bindgen. Then you only have to add the constant you need:
a = bytarr(1000, 1000, 10) + 1b
IDL> help, /mem
heap memory used: 10171230, max: 10171254, gets: 151, frees: 30
There is another way of defining and inititializing an array in one step:
a = make_array(1000, 1000, 10, value=1b)
Initializing such large arrays, you might want to check the time
consumption: On my system (Pentium 200 MHz, IDL 5.1.1 Linux, 64 MB RAM)
the first assignment takes roughly 0.8s, the second takes 1.9s.
(Your code takes 2 minutes! - probably because of swapping to hard disk)
Hope this helps
Kevin
--
Kevin Ivory Tel: +49 5556 979 434
Max-Planck-Institut fuer Aeronomie Fax: +49 5556 979 240
Max-Planck-Str. 2 mailto:Kevin.Ivory@linmpi.mpg.de
D-37191 Katlenburg-Lindau, GERMANY http://www.gwdg.de/~kivory2/
|
|
|