aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2015-03-27 18:46:23 +0100
committerBjörn-Egil Dahlberg <[email protected]>2015-03-27 18:46:23 +0100
commit9a36246ad24561619e182d488d4c8a6825011d34 (patch)
tree237b0985d503f8170fdfcc1960a50d299bb62685
parent8da49848433b060c44d541998d4ac94bf3fd25ea (diff)
downloadotp-9a36246ad24561619e182d488d4c8a6825011d34.tar.gz
otp-9a36246ad24561619e182d488d4c8a6825011d34.tar.bz2
otp-9a36246ad24561619e182d488d4c8a6825011d34.zip
erts: Eliminate potential heap fragments after Map creation
-rw-r--r--erts/emulator/beam/beam_emu.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c
index 8fcdc72895..fdb84aae42 100644
--- a/erts/emulator/beam/beam_emu.c
+++ b/erts/emulator/beam/beam_emu.c
@@ -6573,6 +6573,7 @@ new_map(Process* p, Eterm* reg, BeamInstr* I)
ptr = &Arg(4);
if (n > 2*MAP_SMALL_MAP_LIMIT) {
+ Eterm res;
if (HeapWordsLeft(p) < n) {
erts_garbage_collect(p, n, reg, Arg(2));
}
@@ -6589,7 +6590,15 @@ new_map(Process* p, Eterm* reg, BeamInstr* I)
p->htop = mhp;
factory.p = p;
- return erts_hashmap_from_array(&factory, thp, n/2, 0);
+ res = erts_hashmap_from_array(&factory, thp, n/2, 0);
+ if (p->mbuf) {
+ Uint live = Arg(2);
+ reg[live] = res;
+ erts_garbage_collect(p, 0, reg, live+1);
+ res = reg[live];
+ E = p->stop;
+ }
+ return res;
}
if (HeapWordsLeft(p) < need) {