   telnet server not able to open connections- possible  desktop heap allocation failure
  Hi,My application which is a telnet server running in windows 2003 is not able toaccept more than 10 -20 connections and this number varies. What we believe tobe the reason for this behavior is failure of desktop heap allocation. At thispoint we observe the below event in the system log.Type: WarningSource: Win32kEvent ID: 243Event Time: 10/9/2005 3:51:19 PMUser: n/aComputer: NSHP3IMG01Description:A desktop heap allocation failed.I have tried increasing the values in the below registry key but that did nothelp.HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session\Manager\SubSystems\Windows When this problem is seen, the SSH server on the system was able to accept moreconnections. I could not understand how the SSH server was able to acceptconnections if desktop heap allocation is the cause of the behavior of telnetserver. If this desktop heap allocation failue is the limitation, the SSHserver should also be not able to accept connections.Is the SSH server usingthe desktop heap optimally. Both the servers call functions from user32.dll.My telnet server calls the functions CreateWindowStation(),CreateDesktop(),OpenWindowStation (),CloseWindowStation() from user32.dll .I'll give a outline of where the user32 API functions were called.Process A is a service listening on port 23 which listens for connectionrequests.For each connection request Process A spawns  process B.Process Binturn spawns a command shell.Process A========Process A calls CreateWindowStation("telnet", 0, WRITE_DAC | READ_CONTROL, NULL) before starting a while loop in the service main function. The whileloop calls a function to check for incoming requests which will spawnprocess B(CreateProcess()) if there is a request or else returns to thewhile loop. CloseWindowStation() is called when the service is stopped.Process B========Process B after validating the login credentials spawns a command shell.Below snippet shows what user32 API functions it calls.Some code in between createprocessasuser() and createdesktop() is skipped.-----------------------------------------------   HWINSTA hwinsta;    hwinsta = OpenWindowStation(  "telnet",  FALSE,  READ_CONTROL | WRITE_DAC  );    if (hwinsta == NULL){//error logging}    if (!SetProcessWindowStation(hwinsta))    {    //error logging    }CloseWindowStation(hwinsta);    HDESK dtop=CreateDesktop("dtop", NULL, NULL, 0,GENERIC_ALL, NULL)    if (dtop== NULL) {    //error logging    }    ZeroMemory(&si,sizeof(STARTUPINFO));    GetStartupInfo(&si); //set startupinfo for the spawned process    si.lpDesktop = "dtop";    si.cb = sizeof(si);    FreeConsole();    if(!AllocConsole()){    //error logging    }    //spawn the cmd shell    if (!CreateProcessAsUser(hToken,"c:\winnt\system32\cmd.exe",NULL,NULL,NULL,TRUE,0,NULL,currdir,&si,&pi))--------------------------------------------------Could anyone please help me if there is anything that can be done in the codeto correct the behavior.Thanks in advanceRohini Chandra   