[erlang-questions] Garbage collection

Salikhov Dinislam Dinislam.Salikhov@REDACTED
Mon Dec 19 14:15:05 CET 2016


Thank you for quick response, Dmytro!
I'm afraid you're a bit misled.

 > 2. ProcBins are (iirc) onheap binaries <64 bytes. Each larger binary 
stored on heap is a reference counted pointer to binary heap. Until 
refcount is >0 the binary remains locked.
According to http://erlang.org/doc/efficiency_guide/binaryhandling.html, 
ProcBin is a wrapper for globally stored binary while the latter is 
refcounted.
Heap binaries (<64 bytes) are different thing and are handled without 
ProcBins involved.

On 12/19/2016 03:46 PM, Dmytro Lytovchenko wrote:
> 1. When the process is suspended some external events may happen, such 
> as a kill signal passed to a process. Its value has to be allocated on 
> the process heap, so it is possible that GC is invoked.
> If i remember right, on heap overflow messages will land in heap 
> fragments. Next GC will consolidate them into a single new heap.
>
> 2. ProcBins are (iirc) onheap binaries <64 bytes. Each larger binary 
> stored on heap is a reference counted pointer to binary heap. Until 
> refcount is >0 the binary remains locked.
>
> 2016-12-19 13:29 GMT+01:00 Salikhov Dinislam 
> <Dinislam.Salikhov@REDACTED 
> <mailto:Dinislam.Salikhov@REDACTED>>:
>
>     Hello!
>
>     I've got a couple of questions about garbage collection:
>     1. AFAIU, a process's heap is garbage collected when the process
>     is executed. A process creates and destroys new objects and when
>     there is no enough room for the new object in the heap, GC is invoked.
>     When the process is in scheduler's wait queue, then no new objects
>     are created, so GC isn't called.
>     The only exception, I see, is when new messages are sent to
>     suspended process: they are to be kept in receiver's heap and it
>     may lead to GC invoked.
>     Is my understanding correct? Or there are other possibilities to
>     GC suspended process?
>
>     2. In OTP-19.2 sources,
>     erts/emulator/beam/erl_gc.c:sweep_off_heap() may reallocate
>     ProcBins including the struct binary they point to. The list of
>     ProcBins to realloc is received in link_live_proc_bin(). What
>     prevents us to reallocate the binary that may be referenced by
>     another process?
>
>     Salikhov Dinislam
>     _______________________________________________
>     erlang-questions mailing list
>     erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
>     http://erlang.org/mailman/listinfo/erlang-questions
>     <http://erlang.org/mailman/listinfo/erlang-questions>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161219/e9fa1d52/attachment.htm>


More information about the erlang-questions mailing list