cleanup memory on exit

This commit is contained in:
2024-01-03 14:14:29 +01:00
parent 8af15331d2
commit 41727f1224

View File

@@ -20,6 +20,15 @@ MemoryContext::MemoryContext() {
}
MemoryContext::~MemoryContext() {
// Three times because the first one might not start it as it's been running already
// second one as it might skip something because something has been dirtied
// and the third one everything should be cleaned
request_gc_and_wait();
request_gc_and_wait();
request_gc_and_wait();
assert(cell_count() == 0);
MemoryContext *expected = this;
if (!CURRENT_MC.compare_exchange_strong(expected, nullptr)) {
std::cerr << "Global MC pointer was overwritten!" << std::endl;