HowTo: How to investigate and solve Windows Desktop Heap Problems |
||||||||||||
When installing and starting several services on Windows, you may encounter a problem where it is no longer possible to start additional services. Each Service allocates a certain amount of memory from the internal desktop heap space used to store things such as Windows, Fonts, API elements, etc. When this desktop heap is exhausted, user32 system calls will begin to fail. Unfortunately, it is not currently possible to query the Windows system for the amount of available desktop heap space in advance. When the desktop heap available to the Wrapper process is exhausted, you will most likely encounter one of the following errors:
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 system, the default heap space is 512 KB, but this varies greatly depending on the specific version of Windows that you are running. The Wrapper itself allocates between 10-15 KB for each instance. However, the JVM being launched also allocates at least 20 KB. The exact value varies depending on what the Java application being run is doing. If the heap space is exhausted while the Wrapper process is being loaded, you will get the timeout described above. If it is exhausted while the JVM is being loaded, then you will see one of the other problems. As of this writing, we have not been able to find a way for the Wrapper to query Windows for the amount of remaining desktop heap. It is possible to monitor and diagnose the desktop heap usage using the "Desktop Heap Monitor" tool provided by Microsoft. This tool works by running as a Kernel level driver, which requires a level of access that we do not wish to require the Wrapper to have.
Please read over the instructions on the Microsoft site on using dheapmon.
When dheapmon.
In the above example, the Wrapper is being run as a non-interactive service, running as the System user, in Service-0x0-3e7$\Default. Starting additional non-interactive services as the default System User will increase the heap usage of this desktop accordingly. Running the service as an 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 each individual service. There are 2 workarounds currently available:
64-bit versions of Windows have much larger default desktop heap sizes, so you are much less likely to encounter problems on these systems. |