Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WinHttpSendRequest handle leak

Status
Not open for further replies.

UniDAC

Programmer
Apr 27, 2020
1
0
0
US
I have a WinHttp application that repeatedly sends requests via WinHttpSendRequest. When running this app on a Win10 system, the open handle count after the WinHttpSendRequest call will rise to a particular value (around 370) then stay at that value.

On a Win Server 2016 system, this call results in an increasing number of open handles that continues until I start getting network errors. At that time the open handle count will be around 65,700.

I assume the handle count is due to some pool that WinHttp is managing, probably related to HTTP connections? Why would this count continue to increase on one system and not another ... is there some registry setting that controls this?

Thanks in advance.
 
The documentation does tell you to delete the handle when a response is received.
[URL unfurl="true" said:
https://docs.microsoft.com/en-us/windows/win32/api/winhttp/nf-winhttp-winhttpsendrequest#remarks[/URL]]
An application must not delete or alter the buffer pointed to by lpOptional until the request handle is closed or the call to WinHttpReceiveResponse has completed, because an authentication challenge or redirect that required the optional data could be encountered in the course of receiving the response. If the operation must be aborted with WinHttpCloseHandle, the application must keep the buffer valid until it receives the callback WINHTTP_CALLBACK_STATUS_REQUEST_ERROR with an ERROR_WINHTTP_OPERATION_CANCELLED error code.
Are you waiting for a response or just blindly sending. Could it be that on W10 you are getting responses and therefore deleting the handles but on the server you are not getting responses and not deleting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top