diff options
author | Björn Gustavsson <[email protected]> | 2018-10-24 12:51:35 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2018-10-24 12:51:35 +0200 |
commit | 747001c51a28a35130fa23c9da86683b0801b0a8 (patch) | |
tree | 1098e8ec73b3c6e9c18b812fa652a73323f7c7c4 /erts/emulator/beam | |
parent | b50e4cfd3c48212642799e5a6be8d425a59e4b72 (diff) | |
parent | bc541da07768ab0e11dca183ba235422ae0df593 (diff) | |
download | otp-747001c51a28a35130fa23c9da86683b0801b0a8.tar.gz otp-747001c51a28a35130fa23c9da86683b0801b0a8.tar.bz2 otp-747001c51a28a35130fa23c9da86683b0801b0a8.zip |
Merge pull request #1991 from bjorng/bjorn/erts/fix-max_heap_size/OTP-15360
Honor the max heap size when copying literals after purging
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/bif.c | 4 | ||||
-rw-r--r-- | erts/emulator/beam/erl_gc.c | 19 |
2 files changed, 23 insertions, 0 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c index f18af8bcd7..015c051cc1 100644 --- a/erts/emulator/beam/bif.c +++ b/erts/emulator/beam/bif.c @@ -3622,6 +3622,10 @@ erts_internal_garbage_collect_1(BIF_ALIST_1) default: BIF_ERROR(BIF_P, BADARG); } erts_garbage_collect(BIF_P, 0, NULL, 0); + if (ERTS_PROC_IS_EXITING(BIF_P)) { + /* The max heap size limit was reached. */ + return THE_NON_VALUE; + } return am_true; } diff --git a/erts/emulator/beam/erl_gc.c b/erts/emulator/beam/erl_gc.c index a65dbbf42b..47dd115c82 100644 --- a/erts/emulator/beam/erl_gc.c +++ b/erts/emulator/beam/erl_gc.c @@ -1133,9 +1133,28 @@ erts_garbage_collect_literals(Process* p, Eterm* literals, reds = (Sint64) garbage_collect(p, ERTS_INVALID_HFRAG_PTR, 0, p->arg_reg, p->arity, fcalls, ygen_usage); + if (ERTS_PROC_IS_EXITING(p)) { + return 0; + } ASSERT(!(p->flags & (F_DIRTY_MAJOR_GC|F_DIRTY_MINOR_GC))); + if (MAX_HEAP_SIZE_GET(p)) { + Uint new_heap_size; + Uint old_heap_size; + Uint total_heap_size; + + new_heap_size = HEAP_END(p) - HEAP_START(p); + old_heap_size = erts_next_heap_size(lit_size, 0); + total_heap_size = new_heap_size + old_heap_size; + if (MAX_HEAP_SIZE_GET(p) < total_heap_size && + reached_max_heap_size(p, total_heap_size, + new_heap_size, old_heap_size)) { + erts_set_self_exiting(p, am_killed); + return 0; + } + } + /* * Set GC state. */ |