Skip to content

Commit

Permalink
explicitly use new to avoid exit-time destruction of global state for…
Browse files Browse the repository at this point in the history
… VM (apache#6938)
  • Loading branch information
Trevor Morris committed Dec 2, 2020
1 parent 5d43cfa commit d8ffa64
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/runtime/vm/memory_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ NDArray StorageObj::AllocNDArray(size_t offset, std::vector<int64_t> 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) {
Expand Down

0 comments on commit d8ffa64

Please sign in to comment.