Skip to content

Commit 09262f4

Browse files
authored
Release address space on thread exit (#1188)
The destructor for arena now munmap()s any mapped address space. This is aimed at threads that may exit while the address space remains active for other threads.
1 parent 3c2819a commit 09262f4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/runtime/arena.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <algorithm>
55
#include <cstddef>
66
#include <cstdint>
7+
#include <sys/mman.h>
78
#include <sys/types.h>
89
#include <utility>
910

@@ -22,6 +23,12 @@ class arena {
2223
initialize_semispace();
2324
}
2425

26+
~arena() {
27+
munmap(current_addr_ptr, HYPERBLOCK_SIZE);
28+
if (collection_addr_ptr)
29+
munmap(collection_addr_ptr, HYPERBLOCK_SIZE);
30+
}
31+
2532
char *evacuate(char *scan_ptr);
2633

2734
// Allocates the requested number of bytes as a contiguous region and returns a

0 commit comments

Comments
 (0)