Commit 6df13976 authored by calvin's avatar calvin

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)
parent ea6b2cea
...@@ -186,7 +186,9 @@ os_mem_free_large( ...@@ -186,7 +186,9 @@ os_mem_free_large(
} }
#endif /* HAVE_LARGE_PAGES && UNIV_LINUX */ #endif /* HAVE_LARGE_PAGES && UNIV_LINUX */
#ifdef __WIN__ #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;" fprintf(stderr, "InnoDB: VirtualFree(%p, %lu) failed;"
" Windows error %lu\n", " Windows error %lu\n",
ptr, (ulong) size, (ulong) GetLastError()); ptr, (ulong) size, (ulong) GetLastError());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment