Memory leak using FileMonitorTarget / CacheDependency + DepFileInfo in ASP.NET

In our ASP.NET web application, we are experiencing a fairly extensive memory leak, which I am studying right now. Using WinDbg, I got to the largest memory eaters in our application, which (ran !dumpheap -statin the WinDbg console to get them):

MethodTable Addr   Count  Overall size Type
...
000007fee8306e10   212928     25551360 System.Web.UI.LiteralControl
000007feebf44748   705231     96776168 System.Object[]
000007fee838fd18  4394539    140625248 System.Web.Caching.CacheDependency+DepFileInfo
000007fee838e678  4394614    210941472 System.Web.FileMonitorTarget
000007feebf567b0    18259    267524784 System.Collections.Hashtable+bucket[]
00000000024897c0     1863    315249528      Free
000007feebf56cd0    14315    735545880 System.Byte[]
000007feebf4ec90  1293939   1532855608 System.String

For everyone, I know that a large number of objects Stringcan be quite normal; there is still some room for improvement. But what really makes me itchy is the count of objects System.Web.FileMonitorTarget: we have more than 4 million copies on the heap (48 bytes)! Using two memory dumps and comparing them, I found that these objects are not cleared by the GC.

, , : ? ANTS Memory Profiler, , . System.Web.Caching.CacheDependency+DepFileInfo , , System.Web.Cache, , .

, 14315 System.Byte[], 700 , - , Byte[], - , 30 .

Byte FileMonitorTarget ? !

P.S. - , "" .

+3
2

, . , . . 1,4 . ? , . , .

, FileMonitorTarget / Byte[] , !dumpheap -mt XXX, XXX - MethodTable . , PSSCOR2 SOS, ( !dumpheap -, ).

, , - , . !gcroot , . . , . , , , . , , . , , .

+1

System.Web.Caching.CacheDependency + DepFileInfo ASP.NET -. , FileDependency, ASP.NET .

, /.

0:000> !df -field _filename 0d3f24ec 
Name: System.String
MethodTable: 79330b24
EEClass: 790ed65c
Size: 180(0xb4) bytes
GC Generation: 2
 (C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)
String: C:\inetpub\wwwroot\Website\Application\Base\UserControl\Messages.ascx
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
79332d70  4000096        4         System.Int32  1 instance       82 m_arrayLength
79332d70  4000097        8         System.Int32  1 instance       81 m_stringLength
79331804  4000098        c          System.Char  1 instance       44 m_firstChar
79330b24  4000099       10        System.String  0   shared   static Empty
    >> Domain:Value  000e0ba0:02581198 00109f28:02581198 <<
79331754  400009a       14        System.Char[]  0   shared   static WhitespaceChars
    >> Domain:Value  000e0ba0:025816f0 00109f28:02586410 <<

, : ASP.NET

. GCRoot [obj_addr] , . , IIS/.NET.

, , , , .: | ( , , , ...)

+1

Source: https://habr.com/ru/post/1756785/


All Articles