Skip to content

Commit 3d67cf6

Browse files
authored
[JITLink] Always unmap standard segments in InProcessMemoryManager::deallocate (#81943)
Right now InProcessMemoryManager only releases a standard segment (via sys::Memory::releaseMappedMemory) in `deallocate` when there is a DeallocAction associated, leaving residual memory pages in the process until termination. Despite being a de facto memory leak, it won't cause a major issue if users only create a single LLJIT instance per process, which is the most common use cases. It will, however, drain virtual memory pages if we create thousands of ephemeral LLJIT instances in the same process. This patch fixes this issue by releasing every standard segments regardless of the attached DeallocAction.
1 parent 9c4e2fe commit 3d67cf6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,7 @@ void InProcessMemoryManager::deallocate(std::vector<FinalizedAlloc> Allocs,
449449
for (auto &Alloc : Allocs) {
450450
auto *FA = Alloc.release().toPtr<FinalizedAllocInfo *>();
451451
StandardSegmentsList.push_back(std::move(FA->StandardSegments));
452-
if (!FA->DeallocActions.empty())
453-
DeallocActionsList.push_back(std::move(FA->DeallocActions));
452+
DeallocActionsList.push_back(std::move(FA->DeallocActions));
454453
FA->~FinalizedAllocInfo();
455454
FinalizedAllocInfos.Deallocate(FA);
456455
}

0 commit comments

Comments
 (0)