A memory leak issue occurs if you call the WTSQuerySessionInformation function to query the published applications for session ID 0, or if you to call this function to initialize the program information for session ID 0
Consider the following scenario:
- An application or a service calls the WTSQuerySessionInformation function to query some terminal server session related information.
- The second parameter is 0 and the third parameter is WTSInitialProgram or WTSApplicationName.
In this scenario, under heavy stress conditions, the memory usage of the application or the service keeps increasing.
Further investigation indicates that the WTSQuerySessionInformation function leaks memory. Additionally, the GetLastError function returns an incorrect error code.
For more information on this issue, including potential causes, workarounds, and resolutions, see: Microsoft KB Article KB970910.