I was doing some research on the amount of windows handles that an application can use. I’m using Delphi XE2 and using the AllocateHWnd routine which creates an invisible windows handle by using CreateWindowsEx for receiving and processing of windows messages.
I have found some interesing stuff and I would like to know from the experts why such behaviour.
When creating a service application I can reach up to 2220 handles on a Windows 7 machine, if I activate the option “Allow the service to interact with the desktop” in the service configuration I can reach about 9823 handles!
Windows 2008 runs the same way, I can create ~2220 handles on a non-interactive service and over 9000 on interactive service
I have tested on a Windows 2012 server and even with interactive service flag turned on I can’t create over 2050 handles… Why such limitation and how could I increase it?
I know that a software that uses that much handles is a poorly designed one, but we are testing this for a software that has intensive TCP/IP connection processing which requires many handles to handle inbound and output TCP/IP connections
If my application is a regular desktop application then I can create over 9000 handles even on windows 2012, so, why such limitation on service applications?
Sounds like you face the “desktop heap exhaustion” syndrome.
An excellent explanation about it can be found on Ntdebugging’s Blog:
Anyway, as @DavidHeffernan said, it’s better to redesign your app 🙂