[llvm] 3d67cf6 - [JITLink] Always unmap standard segments in InProcessMemoryManager::deallocate (#81943)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 16 16:20:00 PST 2024
Author: Min-Yih Hsu
Date: 2024-02-16T16:19:56-08:00
New Revision: 3d67cf681a728e4cf0ab9947c0dd07539dda8b74
URL: https://github.com/llvm/llvm-project/commit/3d67cf681a728e4cf0ab9947c0dd07539dda8b74
DIFF: https://github.com/llvm/llvm-project/commit/3d67cf681a728e4cf0ab9947c0dd07539dda8b74.diff
LOG: [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.
Added:
Modified:
llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
index 474a0b5160bcb0..dacf0e6c8aa4f2 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
@@ -449,8 +449,7 @@ void InProcessMemoryManager::deallocate(std::vector<FinalizedAlloc> Allocs,
for (auto &Alloc : Allocs) {
auto *FA = Alloc.release().toPtr<FinalizedAllocInfo *>();
StandardSegmentsList.push_back(std::move(FA->StandardSegments));
- if (!FA->DeallocActions.empty())
- DeallocActionsList.push_back(std::move(FA->DeallocActions));
+ DeallocActionsList.push_back(std::move(FA->DeallocActions));
FA->~FinalizedAllocInfo();
FinalizedAllocInfos.Deallocate(FA);
}
More information about the llvm-commits
mailing list