PRB: Memory Not Freed to OS When Debugging on Windows NT 3.51Last reviewed: July 25, 1997Article ID: Q141153 |
The information in this article applies to:
SYMPTOMSWhen you run an application using a debugger under Windows NT 3.51, some heap-checking flags used by the operating system are changed. One of them prevents the heap from coalescing free blocks. This results in your application committing more memory than it is actually using, which causes a low memory condition to occur.
RESOLUTIONThese flags only exist in Windows NT 3.51; this is not an issue in earlier versions of Windows NT or in Windows 95. It also is not an issue if you have Service Pack 2 or Service Pack 3 installed for Windows NT 3.51. To avoid the heap behavior, change the heap flags for your application. To do this open the registry editor (Regedt32.exe) and create the following key: HKEY_LOCAL_MACHINE Software Microsoft Windows NT Current Version Image File Execution Options myapp.exeWhere 'myapp.exe' is the name of your application's .exe file. For a retail system, create the value:
GlobalFlag = REG_SZ 0x70For a checked system, create the value:
GlobalFlag = REG_SZ 0x4f4470GlobalFlag is a bitmask; here are the heap-related bits:
FLG_HEAP_ENABLE_TAIL_CHECK 0x00000010 FLG_HEAP_ENABLE_FREE_CHECK 0x00000020 FLG_HEAP_VALIDATE_PARAMETERS 0x00000040 FLG_HEAP_VALIDATE_ALL 0x00000080VALIDATE_ALL is the flag that disables coalescing blocks.
STATUSMicrosoft is researching this behavior and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
Steps to Reproduce BehaviorIf you build and run the following sample code, you can reproduce the behavior by following these steps:
Sample Code
/* Compile options needed: /Zi */ #include <windows.h> void main() { int count; char *achar[10]; while (TRUE) { for (count = 0; count < 10; count++) achar[count] = (char*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,10000); for (count = 0; count < 10; count++) HeapFree(GetProcessHeap(),0,achar[count]); } } |
Additional query words: leak leaks GlobalAlloc malloc free new
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |