Closed KKhurin closed 4 years ago
We fixed a bug of this nature a while ago. According to this repro log, you are using an old version of System.Net.Http:
C:\Users\kkhurin\.dnx\runtimes\dnx-coreclr-win-x64.1.0.0-rc1-update1\bin\System.Net.Http.dll
Please make sure you use the latest version of System.Net.Http from the CoreFx dev feed:
https://dotnet.myget.org/gallery/dotnet-core System.Net.Http v4.0.1-rc3-23803
Note that DNX currently "pins" the System.Net.* libraries in its runtimes folders. This makes it difficult to force it to use the latest version of packages. DNX is going away and being replaced by "dotnet cli".
Can you please redo this repro and verify that you are using the latest version of System.Net.Http library?
Also, this WinHttpRequestState object will always be strongly pinned during the lifetime of the HttpResponseMessage. It shows from your log that the HttpResponseMessage object is still alive which means the .Content (response content) is still alive.
0:012> !do 000000841e3aa2a8 ; !do 000000859e5f4ab0
Name: System.Net.Http.HttpResponseMessage
Fields:
MT Field Offset Type VT Attr Value Name
00007fff696e5d90 40000bc 34 System.Boolean 1 instance 0 _disposed
So, you need to "dispose" the HttpResponseMessage in order for the memory to be freed and the WinHttpRequestState to be unpinned.
Does your stress test dispose the HttpResponseMessage at all?
Turns out we still have a cycle between strongly root WinHttpRequestState and the inner field of RequestHandle.
00007ffcec778d28 42738 7863792 System.Net.Http.WinHttpRequestState 0:012> !gcroot 000000e691bf1610 HandleTable: 000000e50ff1b890 (strong handle) -> 000000e691bf1610 System.Net.Http.WinHttpRequestState Plus I see a huge native heap: 0:012> !address -summary --- Usage Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal Free 164 7ffa`a770c000 ( 127.979 TB) 99.98%
566 4`8272b000 ( 18.038 GB) 84.36% 0.01% Heap 339 0`c69d1000 ( 3.103 GB) 14.51% 0.00% Stack 447 0`09040000 ( 144.250 MB) 0.66% 0.00% Image 675 0`0469c200 ( 70.610 MB) 0.32% 0.00% MappedFile 22 0`01e21e00 ( 30.132 MB) 0.14% 0.00% Other 8 0`001bf000 ( 1.746 MB) 0.01% 0.00% TEB 149 0`0012a000 ( 1.164 MB) 0.01% 0.00% PEB 1 0`00001000 ( 4.000 kB) 0.00% 0.00% 0:012> !heapstats 0 Heap Total Total Total WOB WOB WOC WOC Largest Handle Count Size Reserved Size Bytes Size Count Allocation --- 000000e5`0fd00000 2 1,868 65,536 1,807 1,807 0 1 1,807 000000e5`0ffa0000 69,560 1,464,145,196 1,474,506,752 32,768 1,133,772,800 32,768 34,600 32,768 000000e5`0ffb0000 1,446,618 1,760,457,444 1,852,621,664 16,384 567,033,856 20 149,815 9,796,080
This is really fast - ~1GB per 1minute. To repro:
Here are some details: