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

Re: about memory





Craig Markwardt wrote:

> Amar Nayegandhi <anayegan@csee.usf.edu> writes:
>
> > This is a general question about memory management.
> > can i free memory allocated to an array if I have finished using it in
> > the program?  suppose
> > arr_a = fltarr(10000,10000)
> > if i don't need array arr_a anymore, would
> > arr_a = 0
> > free the memory used by arr_a?  I would expect it to now utilize only
> > 2(or 4) bytes of memory.
>
> The answer to the question is "yes," but also "it depends."  The
> answer is "yes" because the memory is indeed made available again to
> the same IDL process.  I use
>
>   A = 0
>
> every day when I am done with a variable.  It's totally legit.  Hong
> may need go no further than this, although I agree that he's dealing
> with extremely large arrays which might be better suited with a tiled
> or chunked approach.
>
> The answer is also "it depends," because it depends on which platform
> you are using.  I believe that under Windows the memory is actually
> returned to the OS.  Thus, other programs are able to use the memory
> again.  Under Unix this is much less likely, so once the memory is
> allocated to one session of IDL, it stays there until the session ends
> (and is not available to another process).  [ I think this is not
> *always* true, but mostly true. ]
>
> Every so often somebody asks, "why is IDL eating all my memory?"  It's
> basically unavoidable.  Sorry for this diversion.
>
> Craig
>
> --
> --------------------------------------------------------------------------
> Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
> Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
> --------------------------------------------------------------------------

Just curious - why not 'delvar,a'? Is this not as effective (or more so) than
'a=0'?