Re: freeing memory in programs [message #3928] |
Thu, 23 March 1995 15:06  |
rivers
Messages: 228 Registered: March 1991
|
Senior Member |
|
|
In article <3ks2kr$ioo@dux.dundee.ac.uk>, pjclinch@dux.dundee.ac.uk (Pete Clinch) writes:
>
> I'm writing a Wave Widgets program that uses some big arrays (256 * 256 *
> 128 MRI image stacks). Some operations require temporary arrays to hold
> significant chunks of this, but I don't want these arrays around full
> time to choke the memory. I can't use DLEVAR as I'm not at the main
> program level, so how do I free up memory? If I had assigned an array
> by, say
>
> TmpArr = MAKE_ARRAY(256,256,128, /INT)
>
> would a subsequent use of something like TmpArr = BYTE(0) or
> TmpArr = MAKE_ARRAY(1) free up the memory, or would it still be taken up
> but no longer accessible?
>
I will free it up for re-use inside IDL. IDL does not return the memory to the
operating system, i.e. those pages remain in the virtual memory your process is
using. If you later allocate another big array inside IDL you will reuse the
memory you previously released. HOWEVER, if you know that you will later be
needing an array of exactly the same size you are better of NOT freeing up the
memory. This is because IDL will fragment the memory you release (allocating
small variables, etc.), and when you need it again there won't be a chunk which
is big enough. IDL will then have to ask OS for more memory, and eventually you
will run out.
____________________________________________________________
Mark Rivers (312) 702-2279 (office)
CARS (312) 702-9951 (secretary)
Univ. of Chicago (312) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars3.uchicago.edu (Internet)
|
|
|