Increasing the Desktop Application Heap

ID: Q126962


The information in this article applies to:

IMPORTANT: This article contains information about editing the registry. Before you edit the registry, make sure you understand how to restore it if a problem occurs. For information about how to do this, view the "Restoring the Registry" Help topic in Regedit.exe or the "Restoring a Registry Key" Help topic in Regedt32.exe.

SYMPTOMS

When you run a large number of Windows-based programs, "Out Of Memory" error messages appear when you attempt to start new programs or try to use programs that are already running, even though you still have plenty of physical and pagefile memory available.


CAUSE

This behavior can occur if the desktop heap in the WIN32 subsystem is depleted.

NOTE


RESOLUTION

WARNING: Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk.

For information about how to edit the registry, view the "Changing Keys And Values" Help topic in Registry Editor (Regedit.exe) or the "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe. Note that you should back up the registry before you edit it. If you are running Windows NT, you should also update your Emergency Repair Disk (ERD).
To correct this problem, increase the size of the desktop heap:

  1. Run Registry Editor (REGEDT32.EXE).


  2. From the
    HKEY_LOCAL_MACHINE subtree, go to the following key:
    \System\CurrentControlSet\Control\Session Manager\SubSystems


  3. Select the Windows value.


  4. From the Edit menu, choose String.


  5. Increase the SharedSection parameter.

    SharedSection specifies the system and desktop heaps using the following format:
    SharedSection=xxxx,yyyy
    where xxxx defines the maximum size of the system-wide heap (in kilobytes) and yyyy defines the size of the per desktop heap. The default value of the per desktop heap under Windows NT 3.5 (512K) can support approximately 2,500 windows. Increasing the desktop heap by 256K or 512K normally provides enough memory to correct "Out of Memory" errors messages.



MORE INFORMATION

Windows NT uses a special memory heap for all Windows-based programs running on the desktop. The desktop heap is used for all objects (windows, menus, pens, icons, etc.). When a large number of Windows-based programs are running, this heap may run out of memory. When there is not enough memory to satisfy an allocation request, the system normally returns an error and notifies the user that they are running low on memory. Some programs do not handle the failure gracefully, and in some cases there may not be enough memory to create the error message dialog box. As a result, the requested operation fails without any indication.

The SharedSection key is a long string when viewed using Registry Editor. The default value for this key is:


   %SystemRoot%\system32\csrss.exe
   ObjectDirectory=\Windows
   SharedSection=1024,3072
   Windows=On
   SubSystemType=Windows
   ServerDll=basesrv,1
   ServerDll=winsrv:GdiServerDllInitialization,4
   ServerDll=winsrv:UserServerDllInitialization,3
   ServerDll=winsrv:ConServerDllInitialization,2
   ProfileControl=Off
   MaxRequestThreads=16 


The first SharedSection value (1024) defines the heap size common to all desktops. This includes the global handle table (Window handles are unique machine wide) and shared system settings (such as SystemMetrics). It is unlikely you would ever need to change this value.

The second SharedSection value (3072) controls the size of the desktop heap (used for Windows objects). This static value is used to prevent ill- behaved applications from consuming too many resources. Because the desktop heap is mapped into each process' address space, this value should not be set to an arbitrarily high value (as it would decrease performance), but should only be increased sufficiently to allow all the desired applications to run.

Additional query words: prodnt low failure fixed size page file


Keywords          : kbenv ntconfig 
Version           : winnt:3.5,3.51,4.0
Platform          : winnt 
Issue type        : 

Last Reviewed: February 26, 1999