runtime icon indicating copy to clipboard operation
runtime copied to clipboard

WinHttpRequestState memory leak when sending WinHttp requests from WinHttpHandler.

Open baal2000 opened this issue 10 years ago • 2 comments

Noticed during code review that there is a potential memory leak in GCHandle and WinHttpRequestState instances when WinHttpHandler.InternalSendRequestAsync() executed repeatedly from asynchronous do/while loop in WinHttpHandler.StartRequest.

Cause: WinHttpRequestState may pin WinHttpRequestState instances multiple times due to missing _operationHandle.IsAllocated check around _operationHandle = GCHandle.Alloc(this):

        public void Pin()
        {
#if DEBUG
            Interlocked.Increment(ref s_dbg_pin);
#endif
            _operationHandle = GCHandle.Alloc(this);
        }

Maybe related to issue #11674

baal2000 avatar Sep 14 '16 02:09 baal2000

cc: @stephentoub

@baal2000 Thanks for finding that bug!

davidsh avatar Sep 14 '16 18:09 davidsh

you are welcome.

baal2000 avatar Sep 14 '16 19:09 baal2000