We are often asked about limitations in relation to the number of concurrent services that can be run under FireDaemon Pro. FireDaemon Pro imposes no limit on the number of services that can be installed. However, CPU, RAM and non-interactive window station desktop heap play important roles in determining the actual limit as to the number of interactive services that can be run under FireDaemon Pro control on a single machine on Session 0.


Symptoms

If you are running a large number of interactive and / or non-interactive services under FireDaemon Pro, you may experience various errors where services fail to start or other system errors are reported in the Windows Event Log. For example,  you might see errors similar to

  • "FireDaemon.exe - Application Error: The application failed to initialize properly (0xc0000142)" in the Windows Event Log
  • the service just starts and then stops with the error "Not enough quota is available to process this command" in the FireDaemon Pro debug log
  • "Desktop heap allocation failure" in the Windows Event Log (Event ID 243) per the screenshot below:

    Desktop heap allocation failure in Win32k


 Other symptoms include:

  1. You try to open an application but it refuses to load or it starts to load and then it disappears

  2. You try to open or use an application but you get an "Out Of Memory" error message

  3. One of your running applications inexplicably quits

  4. When you right-click on your application, nothing happens! The command menu refuses to pop-up

  5. Your web browser simply refuses to load any more windows or tabs

  6. Your application is missing some menus or toolbars

  7. You get the following error messages :

Initialization of the dynamic library <system>\system32\user32.dll failed. The process is terminating abnormally.
Initialization of the dynamic library <system>\system32\kernel32.dll failed. The process is terminating abnormally.

Cause

Whilst at first this might seem like a problem with FireDaemon Pro,  it is actually because the default size of the non-interactive window station desktop heap is too small.

The desktop heap is a section of memory reserved for the storage of menus, hooks, strings and windows. In earlier versions of Windows, this heap was allocated memory from a fixed 48MB system buffer that is also used to store printer data and font drivers. According to Microsoft, in recent versions of Windows, this system buffer maximum size constraint is no longer present and the buffer size is dynamically allocated.

By default, Windows allocates a finite amount of memory for the desktop heap. If the system ever runs out of space in the desktop heap, the system won't be able to load new windows. It's as simple as that!


Resolution

In order to fix this, you need to increase the size of the desktop heap for each desktop that is associated with a "non-interactive" window station. This fix requires a direct modification to the Windows Registry. If you are not familiar with the Registry, Registry editors and editing keys and values then you should probably not attempt this.


Before making ANY changes ensure you completely backup your machine. Then:

  • Start the registry editor: Start-> Run -> regedt32
  • Find the value: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows
  • Modify the third value of the SharedSection to 4096 or higher (n.b. you might find the first two values differ on later versions of Windows):
    SharedSection=1024,20480,4096
  • Reboot the machine


The first value of the SharedSection is the shared heap size, common to all desktops. It's used to store the global handle table and shared system settings. By default, it's set to 1024KB. You generally do not need to modify this value.

The second value is the desktop heap size for each desktop associated with the "interactive" window station. It's used to store user objects like hooks, menus, strings and windows. By default, it's set to 20480KB on Windows 10 - this value may change depending on the version of Windows you have installed. The more users log into the system, the more desktops are created. Consequently, the total "interactive" desktop heap size will increase to reflect the number of desktops created. Each desktop will only have an "interactive" desktop heap of 20480KB.

The third value is the desktop heap size for each desktop associated with the "non-interactive" window station. By default, it is set to 768KB. If this value is not present, the size of the "non-interactive" window station will be the same as that of the "interactive" window station.

Every service process created under a user account will be given a new desktop in a "non-interactive" window station created by the Service Control Manager (SCM). Therefore, each of these services will consume the amount of desktop heap, as specified in the third SharedSection value. The total desktop heap used in both interactive and non-interactive window stations must fit into the system-wide buffer.

Consequently, decreasing the second or third SharedSection values will increase the number of desktops that can be created but will reduce the number of hooks, menus, strings and windows that can be created within each desktop.

On the other hand, increasing the second of third SharedSection values will reduce the number of desktops that can be created but it will increase the number of hooks, menus, strings and windows that can be created within each desktop.

In addition, increasing the third SharedSection value will reduce the total number of user account services that can run successfully on the system.


Your entire HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows registry key may look like below after modification:

%SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,20480,4096 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=sxssrv,4 ProfileControl=Off MaxRequestThreads=16

Reboot the system for the changes to take effect. Some experimentation will be required to fine-tune the values to meet your requirements. Please also see this article for a further description of ShareSection.