Re: Garbage collection and Memory [message #2272 is a reply to message #2105] |
Sun, 12 June 1994 13:28   |
pendleton
Messages: 17 Registered: February 1992
|
Junior Member |
|
|
In article <1994Jun10.223442.13293@mksol.dseg.ti.com>, landers@tsunami.dseg.ti.com (David Landers) writes:
> 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?
>
> |> 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.
>
Here's another hint for using memory efficiently, this time with respect to
large temporary arrays in frequently called procedures.
If you are using a temp array of a fixed number of elements each and every time
you pass a called procedure, you might find it most efficient to put the
variable into a COMMON block. This way, the memory is allocated once and it's
always there. Use an N_ELEMENTS statement, for example, to determine if the
variable has already been defined.
Common Temp_Block, A
If (N_Elements(A) eq 0) then A = FltArr(100000)
A(*) = 0.
If you want to delete the variable at a later time, simply call up your COMMON
block from another procedure and set the variable to 0B.
Jim Pendleton, Programmer Analyst/Technical Services Specialist
GRO/OSSE, Dept. Physics & Astronomy
Northwestern University
j-pendleton@nwu.edu (708) 491-2748 (708) 491-3135 [FAX]
http://www.astro.nwu.edu/astro/pendleton
|
|
|