Re: Strange memory consumption? [message #13155] |
Fri, 16 October 1998 00:00  |
Alex Schuster
Messages: 124 Registered: February 1997
|
Senior Member |
|
|
Kevin Ivory wrote:
> 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
Oh, sorry I didn't make ths clear. Of course you are right, but my code
was intended as some example only in order to demonstrate the effect.
But it occurs several times in my program that I have a huge array and
have to re-initialize it to zero. I didn't expect that creating the
array again would be faster than using arr[*]=0, and that this costs
that much memory.
> 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)
Here it's around 0.3s vs. 1.7s, on an UltraSparc with enough memory.
Alex
--
Alex Schuster Wonko@weird.cologne.de PGP Key available
alex@pet.mpin-koeln.mpg.de
|
|
|