diff --git a/src/runtime/vm/memory_manager.cc b/src/runtime/vm/memory_manager.cc index 4e480507e71a..960b2e20145a 100644 --- a/src/runtime/vm/memory_manager.cc +++ b/src/runtime/vm/memory_manager.cc @@ -110,8 +110,10 @@ NDArray StorageObj::AllocNDArray(size_t offset, std::vector shape, DLDa } MemoryManager* MemoryManager::Global() { - static MemoryManager memory_manager; - return &memory_manager; + // NOTE: explicitly use new to avoid exit-time destruction of global state + // Global state will be recycled by OS as the process exits. + static auto* inst = new MemoryManager(); + return inst; } Allocator* MemoryManager::GetOrCreateAllocator(TVMContext ctx, AllocatorType type) {