[erlang-questions] automatic garbage collection when low memo ry?

Convey Christian J NPRI ConveyCJ@REDACTED
Wed Mar 26 18:51:36 CET 2008


> -----Original Message-----
> From: Matthias Lang [mailto:matthias@REDACTED] 
> Sent: Wednesday, March 26, 2008 12:51 PM
> To: Convey Christian J NPRI
> Cc: erlang-questions@REDACTED
> Subject: Re: [erlang-questions] automatic garbage collection 
> when low memory?
> 
> Convey Christian J NPRI writes:
> 
>  > I've got a program that crashes unless I explicitly call  
> > erlang:garbage_collect() at certain points.  I'm pretty 
> sure the  > problem is that I'm running out of memory simply 
> because the  > garbage collector isn't running often enough.
> 
>  > Does anyone know if there's a way to get Erlang to run the 
> garbage  > collector when memory gets tight?
> 
> I'm at least as pretty sure that there isn't an automatic way 
> to do that.
> 
> Your post weakly implies that you think that the GC is run 
> globally, which is not the case in normal Erlang. GC is on a 
> per-process basis, on that process' heap. So solving this 
> sort of problem typically involves identifying which 
> process(es) is(are) the huge one(s).

Thanks.  I have one control processes and a number of worker processes.  The memory requirements seem to grow as the worker processes do their work, but then they remain high after those processes have returned from their spawned functions.

Two possibilities occur to me:
(1) The spawned worker processes are fragmenting the Linux process' heap, so that each time I kick off a new generation of worker processes they're unable to reuse the memory that the previous generation of worker processes had used, or

(2) The worker processes return their results by sending a message back to the control processes just before they die.  Perhaps their results require lots of memory to hold.

Has anyone seen (1) before?  And regarding (2), is there some way I can calculate the memory usage of an Erlang value (in this case, a list of lists of tuples)?




More information about the erlang-questions mailing list