Memory handling in lists/arrays allocation/deallocation
Subject: Memory handling in lists/arrays allocation/deallocation
From: Richard Fateman
Date: Tue, 26 Dec 2006 10:35:14 -0800
Stavros' comment is quite correct, but I am curious as to how you know you
are using lots of RAM. Are you getting messages from the garbage collector?
If so, what do they say?
When you do those "other operations" are you doing any assignments or
changing the stored 'state' of Maxima? If not, then you are not allocating
any permanent storage at all. You may run out of storage at some
intermediate calculation, however. (If you are not changing the stored
state or printing out something, the loop could be optimized to be very
fast, since it is doing nothing.)
RJF
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Stavros Macrakis
> Sent: Tuesday, December 26, 2006 9:32 AM
> To: Elianto84
> Cc: maxima at math.utexas.edu
> Subject: Re: [Maxima] Memory handling in lists/arrays
> allocation/deallocation
>
> On 12/26/06, Elianto84 <elianto84 at gmail.com> wrote:
> > I'd like to know how to efficiently manage lists/arrays
> > allocation/deallocation in Maxima,
> > 'cause i've experienced that the execution of a code like
> >
> > for i:... do ( /* lots of times */
> > list : certain_function_of_i_that_returns_a_list,
> > ... /* other operations over list */
> > )
> > maybe really RAM-consuming.
>
> Maxima uses Lisp's garbage collector, so there is no need to allocate
> or deallocate memory explicitly. If an object is "reachable", then it
> will not be deallocated. Reachable means that it is programmatically
> accessible either through a variable or through a data structure
> (which directly or indirectly is the value of a variable).
>
> In your example above, since you are re-assigning the variable "list"
> to a new value each time through the loop, earlier values of list are
> not reachable and will be reclaimed -- unless of course they are
> accessible in some other way. If you want to explicitly signal to the
> Maxima/Lisp system that a variable's value is no longer needed, you
> can assign a trivial value to it -- false or 0 or the empty list.
>
> The details of the "other operations" may be relevant. Also beware of
> "intermediate expression explosion" -- sometimes symbolic calculations
> get much larger than you might think.
>
> -s
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>