From ad51dcb5afb479519158162fbc146105d1327571 Mon Sep 17 00:00:00 2001 From: calvin <> Date: Fri, 19 Sep 2008 14:46:46 +0000 Subject: [PATCH] branches/zip: fix Mantis issue #74 Memory leak on Windows The memory leak was due to wrong parameters passed into VirtualFree() call. So, the call fails with Windows error 87. MEM_DECOMMIT can NOT be used along with MEM_RELEASE. And if the parameter is MEM_RELEASE, the size parameter must be 0. The function frees the entire region that is reserved in the initial allocation call to VirtualAlloc. This issue was introduced by r984. Approved by: Heikki (on IM) --- os/os0proc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/os/os0proc.c b/os/os0proc.c index 23d8907ff3d..d8eb004da11 100644 --- a/os/os0proc.c +++ b/os/os0proc.c @@ -186,7 +186,9 @@ os_mem_free_large( } #endif /* HAVE_LARGE_PAGES && UNIV_LINUX */ #ifdef __WIN__ - if (!VirtualFree(ptr, size, MEM_DECOMMIT | MEM_RELEASE)) { + /* When RELEASE memory, the size parameter must be 0. + Do not use MEM_RELEASE with MEM_DECOMMIT. */ + if (!VirtualFree(ptr, 0, MEM_RELEASE)) { fprintf(stderr, "InnoDB: VirtualFree(%p, %lu) failed;" " Windows error %lu\n", ptr, (ulong) size, (ulong) GetLastError());