Re: [long] Mathematica 5.1 and memory: any garbage collection?
- To: mathgroup at smc.vnet.net
- Subject: [mg59737] Re: [mg59697] [long] Mathematica 5.1 and memory: any garbage collection?
- From: Sseziwa Mukasa <mukasa at jeol.com>
- Date: Fri, 19 Aug 2005 04:32:05 -0400 (EDT)
- References: <200508180416.AAA08516@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On Aug 18, 2005, at 12:16 AM, some.poster at use.net wrote:
> My problem lies with the fact that memory used at intermediate
> stage seems
> never be freed, even whith explicit Clear, Remove or any assignment
> to {} or
> . in whatever order.
>
> How can one recover the memory freed (if some is ever effectively
> freed)? Is
> there _any_ garbage collection in the guts of this gazillion
> dollars piece
> of code?
>
> I have no problem with the idea of regularly invoking some function to
> compact the heap (should the kernel be unable to perform it by
> itself). The
> question is: what's its name?
>
> How do you reclaim memory, you serious users who do computations on
> large
> objects with numerous intermediate values?
You analysis is very thorough but you are forgetting that Mathematica
stores copies of evaluated expression in Notebooks in the expressions
In and Out that naturally grow in memory use over time. Your example
does not reflect the memory usage patterns that would happen if you
grouped your statement in a Block or Module type construct because in
that case only a single value would be added to In and Out, namely,
the last one returned from the Block or Module.
You can clear In and Out as described in the help Browser with
Unprotect[In, Out];
Clear[In, Out];
Protect[In, Out];
Checking MemoryInUse after these statements will show the reduction
in memory used. You can control the growth of In and Out with the
$HistoryLength variable described in the Help Browser. Furthermore,
I believe it is the case on most platforms that once an application
requests memory that memory remains assigned to that application
until execution ends, so MaxMemoryUsed will probably increase
monotonically regardless of how you release memory. The important
fact though, is if you remember to clear out In and Out, and release
memory used by other expressions you can reduce the amount of memory
actually used by Mathematica.
Regards,
Ssezi
- References:
- [long] Mathematica 5.1 and memory: any garbage collection?
- From: some.poster@use.net
- [long] Mathematica 5.1 and memory: any garbage collection?