From 10a1f3a2d5d9343bd4d2b8ec77c32ec18da21666 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Thu, 12 Mar 2015 13:42:15 +0100 Subject: erts: Add missing binary offheap overhead in binary_to_term Binary offheap overhead is used to trigger GC when a process is referring "too much" binary offheap data. Offheap binaries created from external format (binary_to_term, distributed messages or compacted ets tables) were not accounted for. Example: A process receiving a lot of binary data in distributed messages, while not building much terms on its heap, could cause an extensive memory consumption for garbage binaries. --- erts/emulator/beam/external.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'erts/emulator/beam/external.c') diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c index 9b9b4b2a62..ae011a34bd 100644 --- a/erts/emulator/beam/external.c +++ b/erts/emulator/beam/external.c @@ -3396,6 +3396,7 @@ dec_term_atom_common: pb->size = n; pb->next = off_heap->first; off_heap->first = (struct erl_off_heap_header*)pb; + OH_OVERHEAD(off_heap, pb->size / sizeof(Eterm)); pb->val = dbin; pb->bytes = (byte*) dbin->orig_bytes; pb->flags = 0; @@ -3449,6 +3450,7 @@ dec_term_atom_common: pb->size = n; pb->next = off_heap->first; off_heap->first = (struct erl_off_heap_header*)pb; + OH_OVERHEAD(off_heap, pb->size / sizeof(Eterm)); pb->val = dbin; pb->bytes = (byte*) dbin->orig_bytes; pb->flags = 0; @@ -3747,6 +3749,7 @@ dec_term_atom_common: hp += PROC_BIN_SIZE; pb->next = off_heap->first; off_heap->first = (struct erl_off_heap_header*)pb; + OH_OVERHEAD(off_heap, pb->size / sizeof(Eterm)); pb->flags = 0; *objp = make_binary(pb); break; @@ -3764,6 +3767,7 @@ dec_term_atom_common: hp += PROC_BIN_SIZE; pb->next = off_heap->first; off_heap->first = (struct erl_off_heap_header*)pb; + OH_OVERHEAD(off_heap, pb->size / sizeof(Eterm)); pb->flags = 0; sub = (ErlSubBin*)hp; -- cgit v1.2.3