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)
This commit is contained in:
calvin 2008-09-19 14:46:46 +00:00
parent d36b83e65b
commit ad51dcb5af

View file

@ -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());