Size of function and memory management

Thomas Lindgren thomasl_erlang@REDACTED
Mon Jan 31 09:47:58 CET 2005


--- Mickael Remond <mickael.remond@REDACTED>
wrote:

> Hello,
> 
> I have a question regarding memory management: What
> is the impact of the 
> size of function on memory management and consumtion
> ?
> What is the impact of very big function (I mean
> printed page long or 
> more) on Erlang memory consumtion ?
> 
> How does the garbage collector react to that ?
> Is the end a execution of a function a way to
> trigger some memory house 
> keeping that would not be triggered otherwise ?

It depends on what the function looks like. In
essence, the compiler has to conceptually check for
sufficient memory at every point where a (big) term is
allocated. As a simple optimization, one generally
merges as many of these checks as possible into a
single one (without overallocating).

Your message hints at stack allocation of data. As far
as I know, there is no stack allocation of data at
this time. Garbage is reclaimed by the ordinary GC
only.

(It might be interesting to investigate the impact of
stack allocation, which need not be *too* difficult.
You need to modify the GC to handle it, implement an
analysis to decide what data can go on the stack, and
generate code to do this well. Though it should also
be said that the idea has never really caught on
despite some attempts in the general functional
arena.)

If you want to trigger memory housekeeping at the end
of a function, insert an erlang:garbage_collect(). But
as the manual says, "improper use may seriously
degrade performance".

Best,
Thomas



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250



More information about the erlang-questions mailing list