@@ -661,6 +661,11 @@ static void* VirtualReserveInner(size_t size, size_t alignment, uint32_t flags,
661661 pRetVal = pAlignedRetVal;
662662 }
663663
664+ #ifdef MADV_DONTDUMP
665+ // Do not include reserved memory in coredump.
666+ madvise (pRetVal, size, MADV_DONTDUMP);
667+ #endif
668+
664669 return pRetVal;
665670}
666671
@@ -765,7 +770,14 @@ bool GCToOSInterface::VirtualDecommit(void* address, size_t size)
765770 // that much more clear to the operating system that we no
766771 // longer need these pages. Also, GC depends on re-committed pages to
767772 // be zeroed-out.
768- return mmap (address, size, PROT_NONE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1 , 0 ) != NULL ;
773+ void * bRetVal = mmap (address, size, PROT_NONE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1 , 0 );
774+
775+ #ifdef MADV_DONTDUMP
776+ // Do not include freed memory in coredump.
777+ madvise (address, size, MADV_DONTDUMP);
778+ #endif
779+
780+ return (bRetVal != NULL );
769781}
770782
771783// Reset virtual memory range. Indicates that data in the memory range specified by address and size is no
@@ -796,6 +808,11 @@ bool GCToOSInterface::VirtualReset(void * address, size_t size, bool unlock)
796808#endif
797809 }
798810
811+ #ifdef MADV_DONTDUMP
812+ // Do not include reset memory in coredump.
813+ madvise (address, size, MADV_DONTDUMP);
814+ #endif
815+
799816 return (st == 0 );
800817}
801818
0 commit comments