Re: Garbage collection and Memory [message #2284 is a reply to message #2105] |
Fri, 10 June 1994 15:34   |
landers
Messages: 45 Registered: May 1993
|
Member |
|
|
In article <1994Jun9.220014.28022@noao.edu>, eharold@corona.sunspot.noao.edu (Elliotte Harold) writes:
|> In article <thompson.770745164@serts.gsfc.nasa.gov>, thompson@serts.gsfc.nasa.gov (William Thompson) writes:
|> |> hevans@estwm0.wm.estec.esa.nl (Hugh Evans) writes:
|> |>
|> |> [ snip ]
|> |>
|> |> It also strikes me that you could save the session, use .RNEW to clear out all
|> |> the memory, and restore it.
|> |>
|>
|> But will this allow you to start up in the middle of a program?
|> i.e. can I Control-C a program; save,/all; save ,/routines; .RNEW;
|> and then restore everything and .continue from where I left off?
No, you can't .RNEW from anywhere but $MAIN$
You could DELVAR each and every variable....
Also, note that the SAVE will only save local variables in whatever subroutine
you happen to interrupt - may not be where you want. So you may not be
able to repack the proper variables.
|> [ snip]
|> Would it help if I cleared temporary variables and arrays every pass through
|> my main loops?
Definately (usually). Clear ( by setting = 0) everything when you're done
with it. Especially arrays. Especially large arrays.
If you have a temp array that you reuse each pass thru a loop, it will eat
memory.
Example:
for i = 0, 1000 do begin
a = something()
... etc...
endfor
In this loop, when the a = something line is encountered, WAVE/IDL mallocs
memory for the result of something(). A is still using memory. Then, memory
for A is free()d, and a is pointed to the new result.
Assuming a is an array (and something() doesn't use it in the calcualtion),
doing this:
a = 0 ; free memory
a = something()
forces WAVE/IDL to free most of a's memory before it goes looking for memory
to use for something().
WAVE/IDL can't (in general) free a before it does something(), because a might
be needed in the calculation.... Only you know if that's so.
;Dave
|
|
|