[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange memory problem



"R. Kyle Justice" wrote:

> When I do the following:
> 
> temp=bytarr(1000,1000,25)
> temp(*)=10
> 
> my computer (a Sparc20 with 128MB of *available* ram) grinds
> to a halt.  Actually it starts using swap.  Don't tell me
> PV-Wave is making 5 or 6 copies of the array just to do this
> simple process!
> 
> Has anyone else seen this curious behavior on PV-Wave?  IDL?  I have
> verified it on a PC, and using different versions of PV-Wave(6.1,7.0).

Yes, I encountered the same problem. It seems that, when using the (*)
notation, IDL (and probably also PV-WAVE) replaces the * by an
appropiate index list, like here:

	temp = bytarr(1000,1000,25)
	index = lindgen(25000000L)
	temp(index) = 10B

This index list takes 100 MB of memory! You can check this by the
command HELP, /MEMORY.

As others have pointed out, it is much faster when you use something
like this:
	temp = bytarr(1000,1000,25)+10B
(Don't forget the B, because you would get an INTARR instead.)

This is much faster, and you need only 25 MB of RAM, as one would
expect.

        Alex
-- 
  Alex Schuster     Wonko@weird.cologne.de          PGP Key available
                    alex@pet.mpin-koeln.mpg.de