Re: freeing memory in programs [message #3930 is a reply to message #3928] |
Fri, 24 March 1995 02:01  |
Fergus Gallagher
Messages: 41 Registered: January 1995
|
Member |
|
|
> Subject: freeing memory in programs
> Date: 23 Mar 1995 15:03:55 -0000
> From: pjclinch@dux.dundee.ac.uk (Pete Clinch)
> Organization: The University, Dundee, DD1 4HN, Scotland, UK.
> Newsgroups: comp.lang.idl-pvwave
>
> 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?
There is the help,/mem command to help you with this. I *suspect* that it
depends on the other memory that's been allocated in the meantime. The
memory is almost certainly available but, generally, in a non-contiguous
block wrt other memory on the heap.
Strangely,
IDL> tmp = intarr(1000,1000) ; say
IDL> print,temporary(tmp)
Help,/mem shows that memory has still been 'lost' in this case.
Note that here I have used an alternative way of 'deallocating' a variable.
(I seem to remember reading somewhere that it is preferable to tmp=0)
Fergus
=================================================
| Fergus Gallagher |
| Remote Sensing Applications Development Unit |
| British National Space Centre |
| Monks Wood |
| Huntingdon PE17 2LS / UK |
| |
| F.Gallagher@nerc.ac.uk |
| http://uh.nmt.ac.uk/bnsc/fgg.html |
=================================================
|
|
|