[erlang-questions] Garbage collection

Dmytro Lytovchenko <>
Mon Dec 19 13:48:55 CET 2016

on 1. Such GC on a suspended process sometimes is DELAYED.
Depends which opcode caused this, some opcodes such as gc_bif have Live
argument which allows running a GC inline, other will have to call GC but

2016-12-19 13:46 GMT+01:00 Dmytro Lytovchenko <>

> 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 <
> com>:
>> 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
>> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161219/52f1756b/attachment.html>

More information about the erlang-questions mailing list