Re: Memory benefit from subroutines [message #55315] |
Mon, 13 August 2007 03:06 |
m_schellens
Messages: 31 Registered: February 2005
|
Member |
|
|
On Aug 10, 7:24 pm, Ed Hyer <ejh...@gmail.com> wrote:
> Hi IDL Wizards,
>
> This has come up a few times, and I realized I don't know the answer:
>
> In the process of eliminating loops, I write a lot of routines that
> hover at the raw edge of what can be done in 32-bit IDL, in terms of
> memory usage. When a complicated routine runs out of memory, I usually
> do a
> IDL> help
> to determine if there's any cleanup I failed to do that could
> alleviate the crunch. Sometimes, though, the big memory hogs are
> outside the current loop. Here's pseudocode for that:
>
> outputarray=fltarr(2,10,2e6); 2e6 data from 200 files
> for ifile=0,199 do begin
> <crazy memory intensive operation>
> outputarray[i,ii,*]=result_1file
> endfor
>
> Now, if I put <crazy memory intensive operation> into a FUNCTION,
> would I gain any headroom on memory, because of descoping OUTPUTARRAY?
>
> Thanks for your sagacity,
>
> --Edward H.
You would gain nothing memory wise.
outputarray is still in memory even when out of scope
(and still even acessible with SCOPE_VARFETCH).
But probably the ASSOC function can be your friend here.
Cheers,
Marc
|
|
|