aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2017-01-17 12:30:36 +0100
committerRickard Green <[email protected]>2017-01-17 12:30:36 +0100
commit6db6cd94682d05eddbfa8b712419e70576d20846 (patch)
treee4038e914b1b262d3b63ebe78a803186bdc721d2 /erts/emulator/beam
parenta44947369f44cb334ca45dbecca2e3f878af8229 (diff)
parent5de2d73abd5d369676e43acd17a9d9db9795ccd5 (diff)
downloadotp-6db6cd94682d05eddbfa8b712419e70576d20846.tar.gz
otp-6db6cd94682d05eddbfa8b712419e70576d20846.tar.bz2
otp-6db6cd94682d05eddbfa8b712419e70576d20846.zip
Merge branch 'rickard/abandoned-heap-bugs' into maint
OTP-14135 * rickard/abandoned-heap-bugs: Fix memory leak of temporary heap
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/erl_gc.c11
-rw-r--r--erts/emulator/beam/erl_gc.h1
-rw-r--r--erts/emulator/beam/erl_process.c18
3 files changed, 7 insertions, 23 deletions
diff --git a/erts/emulator/beam/erl_gc.c b/erts/emulator/beam/erl_gc.c
index a33a81babd..3cbb7adfe0 100644
--- a/erts/emulator/beam/erl_gc.c
+++ b/erts/emulator/beam/erl_gc.c
@@ -110,7 +110,6 @@ typedef struct {
static Uint setup_rootset(Process*, Eterm*, int, Rootset*);
static void cleanup_rootset(Rootset *rootset);
-static void deallocate_previous_young_generation(Process *c_p);
static Eterm *full_sweep_heaps(Process *p,
int hibernate,
Eterm *n_heap, Eterm* n_htop,
@@ -862,7 +861,7 @@ erts_garbage_collect_hibernate(Process* p)
disallow_heap_frag_ref_in_heap(p, heap, htop);
#endif
- deallocate_previous_young_generation(p);
+ erts_deallocate_young_generation(p);
p->heap = heap;
p->high_water = htop;
@@ -1519,7 +1518,7 @@ do_minor(Process *p, ErlHeapFragment *live_hf_end,
disallow_heap_frag_ref_in_heap(p, n_heap, n_htop);
#endif
- deallocate_previous_young_generation(p);
+ erts_deallocate_young_generation(p);
HEAP_START(p) = n_heap;
HEAP_TOP(p) = n_htop;
@@ -1617,7 +1616,7 @@ major_collection(Process* p, ErlHeapFragment *live_hf_end,
disallow_heap_frag_ref_in_heap(p, n_heap, n_htop);
#endif
- deallocate_previous_young_generation(p);
+ erts_deallocate_young_generation(p);
HEAP_START(p) = n_heap;
HEAP_TOP(p) = n_htop;
@@ -1779,8 +1778,8 @@ adjust_after_fullsweep(Process *p, int need, Eterm *objv, int nobj)
return adjusted;
}
-static void
-deallocate_previous_young_generation(Process *c_p)
+void
+erts_deallocate_young_generation(Process *c_p)
{
Eterm *orig_heap;
diff --git a/erts/emulator/beam/erl_gc.h b/erts/emulator/beam/erl_gc.h
index 54ea9ca3c0..9a177b7c59 100644
--- a/erts/emulator/beam/erl_gc.h
+++ b/erts/emulator/beam/erl_gc.h
@@ -157,5 +157,6 @@ void erts_offset_heap(Eterm*, Uint, Sint, Eterm*, Eterm*);
void erts_free_heap_frags(struct process* p);
Eterm erts_max_heap_size_map(Sint, Uint, Eterm **, Uint *);
int erts_max_heap_size(Eterm, Uint *, Uint *);
+void erts_deallocate_young_generation(Process *c_p);
#endif /* __ERL_GC_H__ */
diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c
index 6affbd794c..41741764e8 100644
--- a/erts/emulator/beam/erl_process.c
+++ b/erts/emulator/beam/erl_process.c
@@ -11969,7 +11969,6 @@ erts_cleanup_empty_process(Process* p)
static void
delete_process(Process* p)
{
- Eterm *heap;
ErtsPSD *psd;
struct saved_calls *scb;
process_breakpoint_time_t *pbt;
@@ -12024,13 +12023,8 @@ delete_process(Process* p)
hipe_delete_process(&p->hipe);
#endif
- heap = p->abandoned_heap ? p->abandoned_heap : p->heap;
+ erts_deallocate_young_generation(p);
-#ifdef DEBUG
- sys_memset(heap, DEBUG_BAD_BYTE, p->heap_sz*sizeof(Eterm));
-#endif
-
- ERTS_HEAP_FREE(ERTS_ALC_T_HEAP, (void*) heap, p->heap_sz*sizeof(Eterm));
if (p->old_heap != NULL) {
#ifdef DEBUG
@@ -12042,16 +12036,6 @@ delete_process(Process* p)
(p->old_hend-p->old_heap)*sizeof(Eterm));
}
- /*
- * Free all pending message buffers.
- */
- if (p->mbuf != NULL) {
- free_message_buffer(p->mbuf);
- }
-
- if (p->msg_frag)
- erts_cleanup_messages(p->msg_frag);
-
erts_erase_dicts(p);
/* free all pending messages */