We are developing a console software, with Delphi 7.
To simplify, this software is using an embedded TCP server to answer to external requests from a CGI. These answers contain generated HTML pages with Teechart graphs, and data extracted from a database, using DbExpress.
On Windows 7 and Windows 2008 R2 servers, we noticed significant increase of the run time of our software – 2 or 3 times the original process time on Windows XP or Windows Server 2003 – in a standard context of execution: software launched as a Service with the system user account.
But when our software is launched as a simple user, from command prompt, or directly from the IDE (debug mode), the problem simply disappear.
My first question is : has anyone already noticed this problem?
Using ProcessExplorer, we also noticed that when the software is launched as a service, there is no GDI Handle created, nor is a User Handle. But when the software is launched with a user account, some of these handles are created. With Windows XP and Windows Server 2003, either the software is launched as a service or with a simple user account, these handles are always created.
Can this observation be linked with our problem?
If you already noticed these behaviour, how did you fix the problem?
I think we found the source of our problems. So for those that are looking for a solution, here’s what we’ve done:
Delays are due to the use of Win32 API functions using locals. Using a Locale Identifier functions are now being deprecated in favor of using the Locale Name functions (see http://msdn.microsoft.com/en-us/library/windows/desktop/dd319091%28v=vs.85%29.aspx).
Our developments use significantly “CompareString” (http://msdn.microsoft.com/en-us/library/windows/desktop/dd317759%28v=vs.85%29.aspx), including the use of the indexOf method of the TStringList .The execution of this method (CompareStringA of kernell32) is slowed while running in the user context System (in Session 0).
To get around this problem, we overloaded TStringList with CompareStr instead of CompareString. This workaround suits in our context but CompareStr makes comparisons bit to bit and isn’t case sensitive unlike CompareString. (Not to mention the fact that this method is about 10 times faster … http://www.gefvert.org/blog/archives/651)
Another solution would be to switch to a newer version of the IDE, but we all know that this is another story…