Resource limitation issues in Windows Forms-based applications that are designed in Visual Studio 2005 or in Visual Studio .NET (894500)



The information in this article applies to:

  • Microsoft Visual Studio 2005 Standard Edition
  • Microsoft Visual Studio 2005 Professional Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition

INTRODUCTION

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
  • 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 2000
  • Windows XP
  • Windows Server 2003

MORE INFORMATION

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.

Modification Type:MajorLast Reviewed:2/2/2006
Keywords:kbvs2005swept kbvs2005applies kbWindowsForms kbinfo KB894500 kbAudDeveloper