Garbage collection

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Garbage collection

Salikhov Dinislam
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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Garbage collection

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 <[hidden email]>:
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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Garbage collection

Dmytro Lytovchenko
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 DELAY it.

2016-12-19 13:46 GMT+01:00 Dmytro Lytovchenko <[hidden email]>:
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 <[hidden email]>:
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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Garbage collection

Salikhov Dinislam
In reply to this post by Dmytro Lytovchenko
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 <[hidden email]>:
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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions