INDEX   SEARCH   <--BACK

Changing the desktop heap limit's for windows services

KB ARTICLE: KBE0063
KB DATE: 07/07/2017
REQUIRES VERSION: 7.00 or above

By default there are limits in windows for the number of threads / processes a process can spawn, this limit is greatly reduced for windows services which causes problems with Batch & Print Enterprise / Premium Law edition as it is a large program and can easily go over this heap limit causing printing problems. (missing prints and strange errors etc)

We've found more than 4 threads causes a problem. (actual exe's are 6 including the main thread, 1 monitor thread & 4 print threads)

By default from version 10.03 onwards the program running as a service will detect the heap size in windows and adjust the number of threads internally, the real solution is to increase the desktop heap for services then you can run the number of threads set. to do this:-

  1. Run regedit.exe as administrator

  2. Edit the registry value:

    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows
    
  3. You will see a string like:

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

The critical bit is:     (NOTE: these numbers can be slightly different on different versions of windows)

SharedSection=1024,20480,768

The second number (20480) is the size for interactive sessions. The third number (768) is the size of non-interactive (services) sessions. Note how the third number is 26x smaller than the second. Experimentally, we found that changing this to:

SharedSection=1024,20480,2048

Do not make this value larger than necessary, and no larger than 8192, as each service in your system will consume more of a precious resource.

 

Lastly and not least, you will need to reboot the machine for any of these registry changes to take effect.