diff --git a/FEXCore/Source/Utils/Allocator.cpp b/FEXCore/Source/Utils/Allocator.cpp index 5cad9c014..3d9944a6e 100644 --- a/FEXCore/Source/Utils/Allocator.cpp +++ b/FEXCore/Source/Utils/Allocator.cpp @@ -262,9 +262,19 @@ fextl::vector StealMemoryRegion(uintptr_t Begin, uintptr_t End) { } // Block remaining memory gaps + bool SupportsDontDump = true; for (auto RegionIt = Regions.begin(); RegionIt != Regions.end(); ++RegionIt) { auto Alloc = ::mmap(RegionIt->Ptr, RegionIt->Size, PROT_NONE, MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1, 0); + if (SupportsDontDump) { + // Mark these regions as don't dump so that coredump doesn't try dumping large unmapped regions. + // Ideally coredump would be smart enough to only dump resident pages, but here we are. + auto Result = madvise(RegionIt->Ptr, RegionIt->Size, MADV_DONTDUMP); + if (Result == -1) { + SupportsDontDump = false; + } + } + LogMan::Throw::AFmt(Alloc != MAP_FAILED, "StealMemoryRegion: mmap({}, {:x}) failed: {}", fmt::ptr(RegionIt->Ptr), RegionIt->Size, errno); LogMan::Throw::AFmt(Alloc == RegionIt->Ptr, "mmap returned {} instead of {}", Alloc, fmt::ptr(RegionIt->Ptr)); }