This article has been archived. It is offered "as is" and will no longer be updated.
You may experience resource limitation issues in Microsoft Windows Forms-based applications if the applications are built on the Microsoft .NET Framework 1.0 or on the .NET Framework 1.1. These resource limitation issues may occur when you run these applications on Microsoft Windows 9x-based operating systems. The following are the Windows 9x-based operating systems:
Windows 98 Second Edition
Windows Millennium Edition
Developers and application designers should consider the differences between the way that resources are handled in the Windows 9x-based operating systems and the way that resources are handled in the Windows NT-based operating systems. The following are the Windows NT-based operating systems:
Windows NT 4.0
Windows Server 2003
The .NET Framework 1.0 supports Windows 9x-based operating systems to their limits. The .NET Framework 1.1 supports the Windows NT-based operating systems to their limits. However, the limits for the operating systems are different. Therefore, if you design and build a Windows Forms-based application on a Windows NT-based computer, and then you deploy and run the application on a Windows 9x-based computer, the application may experience resource limitation issues.
When you stress-test these applications, you may receive the Win32 API "Error creating window handle" error message. Windows NT-based computers are limited to 10,000 Graphics Device Interface (GDI) handles per process. Windows 9x-based computers are limited to only 1,200 GDI handles for the whole system. In some versions of Windows, the limit is 640 GDI handles, and all applications must share these GDI handles. For example, the Japanese version of Windows Millennium Edition has a limit of 640 GDI handles. This problem may also occur in unmanaged C language-based applications.
To minimize the effect of the resource limitations, use one or more of the following methods:
Make sure that you create only graphical controls that will be rendered. Fewer resources are available to applications when you allocate resources to hidden controls or to arrays of controls.
Be careful when you use graphical objects such as pens and brushes that allocate GDI handles. The .NET Framework 1.0 and the .NET Framework 1.1 do not always release their resources until the Dispose method is called.
Force garbage collection before new GDI objects are allocated. To force garbage collection, call the Dispose method for objects that you do not need. Later, you can call the GC.Collect method and the GC.WaitForPendingFinalizers method to force cleanup of those objects and to release those objects. We do not recommend this method for Windows NT-based systems. However, you may have to use this method to work around the resource limitations of the Windows 9x-based operating systems.