PRB: User32.dll Leaks Memory |
Q184807
An increasing amount of memory appears to be consumed by an application that repeatedly loads and unloads the User32.dll. This may be caused by the application or a DLL used by the application that loads and unloads the User32.dll multiple times. If the User32.dll is loading and unloading several times, a message box might appear stating an error occurred.
User32.dll does not free its resources when it is unloaded.
Load User32.dll once per application.
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
An application may notice that it is consuming an increasing amount of memory during its execution lifetime even though it does not use any functions that are exported from User32.dll. This may be caused by the application loading and unloading a DLL that uses a function exported from User32.dll.
#include <windows.h>
#include <stdio.h>
BOOL WINAPI DllMain(HINSTANCE hInstance,
DWORD dwReason, LPVOID lpReserved )
{
if (dwReason == DLL_PROCESS_ATTACH)
HBRUSH hbr = GetSysColorBrush( COLOR_BTNFACE );
else if (dwReason == DLL_PROCESS_DETACH)
{}
else if (dwReason == DLL_THREAD_ATTACH)
{}
else if (dwReason ==DLL_THREAD_DETACH)
{}
return TRUE;
}
#include "stdio.h"
void main (int argc, char **argv)
{
int attempt = 0;
HMODULE hInst;
while (attempt++ < 2500)
{
hInst = LoadLibrary ("..\\TestDLL.dll");
printf("Attempt %d: DLL Instance %08lX\n",attempt,hInst);
if (hInst == NULL)
printf("LoadLibrary failed on attempt %d.\nLast error
reports : %d\n", attempt,GetLastError());
else
FreeLibrary(hInst);
} }For additional information, please see the following article in the Microsoft Knowledge Base:
Q171145 PRB: Resource Leaks in System Components
Additional query words: GDI MFC
Keywords : kbAPI kbDLL kbKernBase kbPerfMon _IK kbGrpDSKernBase
Issue type : kbprb
Technology : kbWinNTsearch kbWinNTWsearch kbWinNTW400 kbWinNTW400search kbWinNT400xsearch kbWinNTSsearch kbWinNTS400xsearch kbWinNTS400 kbWin95search kbZNotKeyword3
|
Last Reviewed: December 16, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |