World Map
Java Service Wrapper is the easiest way to make your product more reliable.
  • Free Trial
  • Buy Now

How to fix problems running a large amount of services with the Wrapper on Windows

Compatibility : 1.0.0
Editions :Professional EditionStandard EditionCommunity Edition
Platforms :WindowsMac OSX (Not Supported)Linux (Not Supported)IBM AIX (Not Supported)FreeBSD (Not Supported)HP-UX (Not Supported)Solaris (Not Supported)IBM z/OS (Not Supported)IBM z/Linux (Not Supported)

When installing and starting services running with the Wrapper, you might hit a point at which it seems it won't be possible to start any further service anymore.

Usual indications for this are:

  • Starting the application yields almost instantly a Timeout. "Error 1053: The service did not respond to the start or control request in a timely fashion"

  • The Service starts, but the JVM is instantly exiting with exit code 6 (due to failing to load internal dlls).

  • The Service starts, but fails to allocate a console.

Each Service is allocating a certain amount of memory from the internal desktop heap space used to store things such as API elements etc.. A detailed description of the internal desktop heap can be found on the external site. If the service is launched as non-interactive Service, on a 32-bit Windows XP the default heap space is 512KB. The Wrapper itself is allocating around 10-15 KB for each instance, being started. Each JVM will also allocate around 20 KB, however, this value can vary depending on the API elements, the JVM is loading. If the heap space is exhausted when the service is attempted to start, above errors can be the consequence.

The desktop heap can be diagnosed with the Desktop Heap Monitor tool provided by Microsoft. After installed and configured the output should look like this:

C:\kktools\dheapmon8.1\x86>dheapmon.exe
Desktop Heap Information Monitor Tool (Version 8.1.2925.0)
Copyright (c) Microsoft Corporation.  All rights reserved.
-------------------------------------------------------------
  Session ID:    0 Total Desktop: (  5824 KB -    7 desktops)

  WinStation\Desktop            Heap Size(KB)    Used Rate(%)
-------------------------------------------------------------
  WinSta0\Default                    3072              8.2
  WinSta0\Disconnect                   64              4.5
  WinSta0\Winlogon                    128              9.8
  Service-0x0-3e7$\Default            512             28.8
  Service-0x0-3e4$\Default            512              2.1
  Service-0x0-3e5$\Default            512              3.1
  SAWinSta\SADesktop                 1024              0.3
-------------------------------------------------------------

The non-interactive services, which run as System user, belong in this case to Service-0x0-3e7$\Default. Starting more non-interactive services (run as System User) will increase the heap usage accordingly. Running the service as interactive service will cause the WinSta0\Default heap space usage to increase. Running the Service under a certain user account will create a new WinStation\Desktop session for the process. Any Service which will be run as this user will actually receive a own session.

There are 2 workarounds currently available:

  • Running as certain service user account. Each Service which will be run will receive a own session until 48 MB, which is globally available on 32 bit machines

  • Increase the non-interactive desktop heap space on the local machine following the instructions on the Microsoft site

A 64-bit Windows has a significantly larger desktop heap space and therefore it needs much more services being running at the same time to eventually reach the limit.