PRB: Resource Leaks in System Components

ID: Q171145

The information in this article applies to:

SYMPTOMS

If you load and free a system DLL (for example, USER32.DLL, ADVAPI32.DLL, or GDI32.DLL) repeatedly in your Win32 application, a resource leak occurs under Windows NT.

CAUSE

This behavior is by design. The Windows NT system DLLs ADVAPI32.DLL, USER32.DLL, and GDI32.DLL are meant to be loaded only once, that is, when your application is loaded. System DLLs make no attempt to clean up resources when they are unloaded. System DLLs rely on the operating system to clean up all their resources when the associated process terminates.

WORKAROUND

There are two ways to work around this problem:

-or-

REFERENCES

For additional information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q184807
   TITLE     : BUG: User32.dll Leaks Memory

Additional query words:
Keywords          : kbprg kbtshoot kbDLL kbKernBase kbGrpKernBase 
Version           : 3.51 4.0
Platform          : NT WINDOWS
Issue type        : kbprb

Last Reviewed: August 7, 1998