Friday, December 28, 2007

Understanding Desktop Heap from an Apps DBA perspective

One of the issues that an Apps DBA might encounter sooner or later on WINDOWS 2000/2003 platform is "The application failed to initialize properly (0xc0000142). Click on OK to terminate the application." error in the event log of the server. This would also contain the name of executable that could not be initialized. This could be any of the oracle applications executables like OAMKSVC.exe, Apache.exe, ifweb60.exe and so on..If you check the memory availability using the "Task Manager" you will see plenty of memory available.

The Problem:

The above scenario implies that you are running into "desktop heap" issue. Let me try to explain in simple words what desktop heap means, the underlying important aspects from troubleshooting perspective. Desktop heap simply refers to a memory area within a session, which is used to store certain user interface objects like windows. Every process requires a desktop object to run under, every desktop requires a window station to run under and every window station requires a session to run under. One session can have only one interactive window station, but more than one non-interactive winstation. Also, there are three types of desktops - Default, Disconnect and winlogon. This also implies that one window station can have all three types of desktops running under it. I think that Disconnect and winlogon are applicable in a terminal services environment.

The question that would immediately arise is - how does this all relate to my "apache / forms" applications running as a service?

The (apache/forms or any other) service is considered as a "non-interactive" window station and implicitly uses a "Default" desktop. Windows operating system allows you to configure "Default" desktop heap value for both Interactive and non-interactive window stations separately.

Ascertain the issue:

One of the tools available to monitor and ascertain the presence of desktop heap issue is dheapmon. Run this tool to determine the status of desktop heap.

Settings and Corrective Action:

You can configure the value of "default" desktop heap for "interactive" and "non-interactive" window station using the following registry entry: HKLM\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows.

The value would look something like %SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,3072,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ProfileControl=Off MaxRequestThreads=16

The second and third value (KBs) in the "SharedSection" in the above value represent the desktop heap for interactive and non-interactive window stations. This can be configured. However, please note that each of the sessions would allocate this amount of desktop heap for every "default" desktop running under the session.

Note that if your apache service is running with the "LocalSystem" account, without the "Allow service to interact with desktop" option, then the amount of desktop heap available is 512 (per the above example). This value is allocated for each service as each of the service is considered as non-interactive desktop. However, when you have large number of concurrent users using the forms or apache, the chances are 512 KB is not enough. In such situations, you can check the "Allow service to interact with desktop" option, there by leveraging on the interactive desktop heap value for the Window station 0 (console), which is 3072. One word of caution here, if 3072 is depleted, your apache will be "hung" until someone clicks on the "OK" button on the console for the apache to continue.

The downside of increasing the 512 value of the non-interactive window station to 3072 is that, every service will occupy this amount of memory. This applies to every service that you may have on the server like anti-virus software, backup software, volume manager softwares, system management softwares etc.


One last word, do not worry about the "disconnect and winlogon" desktop heaps, as issues are infrequent in this area. I am not aware if these are configurable or not either.

Wish You Happy Holidays and Happy New Year.

- Aravind Kamath

No comments: