Discussion:
WinINet APIs appear to be leaking handles
(too old to reply)
coder1024
2006-03-13 12:41:27 UTC
Permalink
My application is periodically (twice per minute) using HTTP to submit
information to a web server and to download information from it using the
WinINet APIs.

After running overnight, I noticed in Task Manager that the #of handles had
grown rather large. Using WinDbg and the handle utility from the
sysinternals web site, I was able to discover that the handle growth was all
registry key handles and that it was the same key over and over (over a
thousand of these so far). The key being leaked is shown below.

HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap

My sequence of calls is shown below.

InternetOpen <at initialization>

--- for each request ---
InternetCrackUrl
InternetConnect
InternetSetOption
HttpOpenRequest
HttpAddRequestHeaders
HttpSendRequest
HttpQueryInfo
InternetReadFile

InternetClose <at shutdown>

I've gone through my code and it appears I'm releasing any handle I'm given,
so it seems like the leak is internal. Is there any workaround for this?
Scherbina Vladimir
2006-03-13 17:34:45 UTC
Permalink
coder1024,

I did not met such problem when using wininet.
Can you publish (attach to letter) a piece of code that causes the problem ?
--
Vladimir
http://spaces.msn.com/vladimir-scherbina/
s***@gmail.com
2006-03-21 20:52:19 UTC
Permalink
I'm not coder1024, but I've seen a lot of leaks to a handle to
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet
Settings\ZoneMap, both in my app and in IE, ever since hotfix 896688.
I can't pare down my code easily, but there's an easy repro: boot
post-896688 IE to about:blank and click refresh. The handle count
grows by 2 with each refresh. I assume this is the same leak I'm
seeing.

There was a rumor last December on
microsoft.public.windows.inetexplorer.ie6.browser that there was a fix
coming in February 2006, but I haven't seen anything since then.

Thanks,

Steve
Gilbert
2006-04-21 13:49:01 UTC
Permalink
I don't see where you are closing the session handle created by
InternetConnect. Try closing it as soon as you're done with the session.
Post by coder1024
My application is periodically (twice per minute) using HTTP to submit
information to a web server and to download information from it using the
WinINet APIs.
After running overnight, I noticed in Task Manager that the #of handles had
grown rather large. Using WinDbg and the handle utility from the
sysinternals web site, I was able to discover that the handle growth was all
registry key handles and that it was the same key over and over (over a
thousand of these so far). The key being leaked is shown below.
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap
My sequence of calls is shown below.
InternetOpen <at initialization>
--- for each request ---
InternetCrackUrl
InternetConnect
InternetSetOption
HttpOpenRequest
HttpAddRequestHeaders
HttpSendRequest
HttpQueryInfo
InternetReadFile
InternetClose <at shutdown>
I've gone through my code and it appears I'm releasing any handle I'm given,
so it seems like the leak is internal. Is there any workaround for this?
Loading...