From: Max Mouratov Date: Sun, 21 Oct 2012 14:39:17 +0000 (+0600) Subject: Fix: VirtualAlloc leaks when freeing the heap on win32 X-Git-Tag: gc7_4_0~100 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=376e63f889300ea1becab97cf9b1637b53a64e91;p=gc Fix: VirtualAlloc leaks when freeing the heap on win32 --- diff --git a/os_dep.c b/os_dep.c index df5ebdb0..2074f465 100644 --- a/os_dep.c +++ b/os_dep.c @@ -2308,7 +2308,14 @@ void * os2_alloc(size_t bytes) # endif GC_heap_bases[GC_n_heap_bases] = 0; } - } + + // Avoiding the VirtualAlloc leak + } else { + while (GC_n_heap_bases > 0) { + VirtualFree(GC_heap_bases[--GC_n_heap_bases], 0, MEM_RELEASE); + GC_heap_bases[GC_n_heap_bases] = 0; + } + } } #endif /* USE_WINALLOC || CYGWIN32 */