从内存转储中获取详细信息 asp.net 缓存和会话详细信息
Getting the details asp.net cache and session details from memory dump
我的应用程序已经投入生产一段时间了,它有一些经典的 asp 和 asp.net 4.5 代码 运行。
环境:Windows 2008 R2 服务器
两台服务器,负载均衡,在 proc Session 中,内置来自 system.web namespace
的 http 缓存
随着最新的部署,应用程序开始消耗大量内存,并且正在查明内存使用情况。
我为高内存场景捕获了一个大内存转储,我正试图逐一找出内存使用情况。
!地址-摘要
--- Usage Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal
Free 448 c9b0400 ( 2.151 Gb) 78.79%
<unclassified> 2150 21b4a0000 ( 1539.289 Mb) 62.06% 13.17%
Image 1367 d593000 ( 213.574 Mb) 24.58% 5.21%
Stack 354 7385000 ( 115.520 Mb) 13.29% 2.82%
TEB 118 76000 ( 472.000 kb) 0.05% 0.01%
ActivationContextData 8 f000 ( 60.000 kb) 0.01% 0.00%
CsrSharedMemory 1 5000 ( 20.000 kb) 0.00% 0.00%
--- Type Summary (for busy) ------ RgnCount ----------- Total Size -------- %ofBusy %ofTotal
MEM_PRIVATE 1803 1f4b9000 ( 500.723 Mb) 57.63% 12.22%
MEM_IMAGE 2116 121f0000 ( 289.938 Mb) 33.37% 7.08%
MEM_MAPPED 79 4e43000 ( 78.262 Mb) 9.01% 1.91%
--- State Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal
MEM_FREE 448 c9b04000 ( 3.151 Gb) 78.79%
MEM_COMMIT 3151 23a5d0000 ( 1570.363 Mb) 65.64% 13.93%
MEM_RESERVE 847 12a8f000 ( 298.559 Mb) 34.36% 7.29%
--- Protect Summary (for commit) - RgnCount ----------- Total Size -------- %ofBusy %ofTotal
PAGE_EXECUTE_READ 259 f091000 ( 240.566 Mb) 27.69% 5.87%
PAGE_READWRITE 1377 c80f000 ( 200.059 Mb) 23.02% 4.88%
PAGE_READONLY 679 4657000 ( 70.340 Mb) 8.10% 1.72%
PAGE_READWRITE|PAGE_WRITECOMBINE 17 2016000 ( 32.086 Mb) 3.69% 0.78%
PAGE_WRITECOPY 311 e9f000 ( 14.621 Mb) 1.68% 0.36%
PAGE_EXECUTE_READWRITE 212 921000 ( 9.129 Mb) 1.05% 0.22%
PAGE_READWRITE|PAGE_GUARD 236 239000 ( 2.223 Mb) 0.26% 0.05%
PAGE_EXECUTE_WRITECOPY 60 157000 ( 1.340 Mb) 0.15% 0.03%
--- Largest Region by Usage ----------- Base Address -------- Region Size ----------
Free 80010000 7fde6000 ( 1.998 Gb)
<unclassified> 25b0000 1d78000 ( 29.469 Mb)
Image 61feb000 f4b000 ( 15.293 Mb)
Stack ce0000 fd000 (1012.000 kb)
TEB ffdf8000 1000 ( 4.000 kb)
ActivationContextData 50000 4000 ( 16.000 kb)
CsrSharedMemory 7efe0000 5000 ( 20.000 kb)
我已经计算出 GC 堆和地址数据并显示大量内存使用
0:000> !eeheap -stat
Number of GC Heaps: 1
generation 0 starts at 0x273de070
generation 1 starts at 0x273a1000
generation 2 starts at 0x025b1000
ephemeral segment allocation context: none
segment begin allocated size
025b0000 025b1000 035aff50 0xffef50(167729448)
0ea00000 0ea01000 0f9ffd20 0xffed20(167723848)
19a20000 19a21000 1aa1fe54 0xffee54(167726928)
2a750000 2a751000 2b6fb10c 0xfaa10c(164252288)
263a0000 263a1000 26df1224 0xa50224(108139888)
273a0000 273a1000 274a4c70 0x103c70(10640488)
Large object heap starts at 0x035b1000
segment begin allocated size
035b0000 035b1000 04307138 0xd56138(139840568)
1dc60000 1dc61000 1e580050 0x91f050(95642408)
20490000 20491000 206cc878 0x23b878(23409848)
Total Size: Size: 0x63ab464 (104510564) bytes.
------------------------------
GC Heap Size: Size: 0x63ab46445 (1045105648) bytes.
还有 dumpheap 统计信息(它没有显示一个特定对象使用了所有内存,而是显示了很多对象(我的猜测)
05ef4e70 1615 516800 DevExpress.XtraEditors.ViewInfo.TextEditViewInfo
66418298 11091 763524 System.Windows.EffectiveValueEntry[]
7219a874 24397 780704 System.EventHandler
7219f680 10866 918152 System.Int32[]
6592dc98 9502 932360 System.Xaml.XamlNode[]
05ab1bf4 7180 1091360 DevExpress.Utils.AppearanceObject
05ffd498 2010 1101480 Infragistics.Win.UltraWinGrid.UltraGridColumn
72198390 19429 1165740 System.Reflection.RuntimeMethodInfo
721a12a4 4261 1199184 System.Collections.Hashtable+bucket[]
7219dc28 23649 1474820 System.Object[]
721a2518 13502 7978588 System.Byte[]
7219d834 237668 15219668 System.String
003aa9b0 45181 37740118 Free
Total 1282570 objects
Fragmented blocks larger than 0.5 MB:
Addr Size Followed by
2b3cc938 0.5MB 2b454220 DevExpress.Xpo.Helpers.ObjectRecord
2b454248 0.8MB 2b5295d8 DevExpress.Xpo.Helpers.ObjectRecord
2b6680b0 0.6MB 2b6f9e18 DevExpress.Utils.AppearanceObject
请注意,从上面的命令我 removed/edited 一些对象名称(因为它是公司特定的,但我认为你有整体的想法)
我们在会话和缓存中存储了大量数据,想检查一下为 asp.net 缓存和会话数据存储了多少数据。查看此内容的最佳方式是什么?
You can use the MEX.dll extension with Full memory dump and windbg.
然后您可以 运行 命令 AspNetCache -stats 和 AspNetCache -nosession
0:000> **!AspNetCache -stats**
# Items Type Name
======= =====================================================
15 ABC.Core.Services.Cache.NewDataCache
==trimmed============
Total Entries: 25
0:000> !AspNetCache -nosession
CacheItem: 0eca63dc
Key: 0ec9370c "rfq" [3] (System.String)
Value: 0ec93bf0 (App.Core.Services.Cache.NewDataCache)
CacheItem: 0eca6948
Key: 0ec93720 "contriInstrument" [16] (System.String)
Value: 0eca647c (App.Core.Services.Cache.ContriInstrumentCache)
CacheItem: 0eca6e5c
Key: 0ec93750 "alarmSetting" [12] (System.String)
Value: 0eca6990 (App.Core.Services.Cache.ContriInstruAlarmSettingCache)
CacheItem: 0eca7898
Key: 0ec93778 "contribAlarm" [12] (System.String)
Value: 0eca6ec0 (App.Core.Services.Cache.NewDataCache)
CacheItem: 0eca82c8
Key: 0ec937a0 "contribIndicator" [16] (System.String)
Value: 0eca78fc (App.Core.Services.Cache.NewDataCache)
然后你有 !DumpAspNetSession 命令,它将转储所有会话 details.here 的帮助
:000> !mex.dumpaspnetsession -?
!DumpAspNetSession - Prints information on ASP.NET InProc Sessions
Usage:
!DumpAspNetSession -id <sessionid>
-id <sessionid> : Displays detailed information for the session with the specified id
!DumpAspNetSession {-locked2 | -locked}
-locked2 : Alternate presentation for -locked
-locked : Displays all ASP.NET sessions that are polling for an exclusive lock
!DumpAspNetSession -ctx <httpContext>
-ctx <httpContext> : Displays detailed information for the session associated with an HttpContext
!DumpAspNetSession [<addr>]
addr : Displays detailed information for the specified session
!DumpAspNetSession
Displays all In-Proc ASP.NET sessions
!DumpAspNetSession [-?|-h]
-?|-h|-help : Display this help text
我的应用程序已经投入生产一段时间了,它有一些经典的 asp 和 asp.net 4.5 代码 运行。
环境:Windows 2008 R2 服务器 两台服务器,负载均衡,在 proc Session 中,内置来自 system.web namespace
的 http 缓存随着最新的部署,应用程序开始消耗大量内存,并且正在查明内存使用情况。
我为高内存场景捕获了一个大内存转储,我正试图逐一找出内存使用情况。
!地址-摘要
--- Usage Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal
Free 448 c9b0400 ( 2.151 Gb) 78.79%
<unclassified> 2150 21b4a0000 ( 1539.289 Mb) 62.06% 13.17%
Image 1367 d593000 ( 213.574 Mb) 24.58% 5.21%
Stack 354 7385000 ( 115.520 Mb) 13.29% 2.82%
TEB 118 76000 ( 472.000 kb) 0.05% 0.01%
ActivationContextData 8 f000 ( 60.000 kb) 0.01% 0.00%
CsrSharedMemory 1 5000 ( 20.000 kb) 0.00% 0.00%
--- Type Summary (for busy) ------ RgnCount ----------- Total Size -------- %ofBusy %ofTotal
MEM_PRIVATE 1803 1f4b9000 ( 500.723 Mb) 57.63% 12.22%
MEM_IMAGE 2116 121f0000 ( 289.938 Mb) 33.37% 7.08%
MEM_MAPPED 79 4e43000 ( 78.262 Mb) 9.01% 1.91%
--- State Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal
MEM_FREE 448 c9b04000 ( 3.151 Gb) 78.79%
MEM_COMMIT 3151 23a5d0000 ( 1570.363 Mb) 65.64% 13.93%
MEM_RESERVE 847 12a8f000 ( 298.559 Mb) 34.36% 7.29%
--- Protect Summary (for commit) - RgnCount ----------- Total Size -------- %ofBusy %ofTotal
PAGE_EXECUTE_READ 259 f091000 ( 240.566 Mb) 27.69% 5.87%
PAGE_READWRITE 1377 c80f000 ( 200.059 Mb) 23.02% 4.88%
PAGE_READONLY 679 4657000 ( 70.340 Mb) 8.10% 1.72%
PAGE_READWRITE|PAGE_WRITECOMBINE 17 2016000 ( 32.086 Mb) 3.69% 0.78%
PAGE_WRITECOPY 311 e9f000 ( 14.621 Mb) 1.68% 0.36%
PAGE_EXECUTE_READWRITE 212 921000 ( 9.129 Mb) 1.05% 0.22%
PAGE_READWRITE|PAGE_GUARD 236 239000 ( 2.223 Mb) 0.26% 0.05%
PAGE_EXECUTE_WRITECOPY 60 157000 ( 1.340 Mb) 0.15% 0.03%
--- Largest Region by Usage ----------- Base Address -------- Region Size ----------
Free 80010000 7fde6000 ( 1.998 Gb)
<unclassified> 25b0000 1d78000 ( 29.469 Mb)
Image 61feb000 f4b000 ( 15.293 Mb)
Stack ce0000 fd000 (1012.000 kb)
TEB ffdf8000 1000 ( 4.000 kb)
ActivationContextData 50000 4000 ( 16.000 kb)
CsrSharedMemory 7efe0000 5000 ( 20.000 kb)
我已经计算出 GC 堆和地址数据并显示大量内存使用
0:000> !eeheap -stat
Number of GC Heaps: 1
generation 0 starts at 0x273de070
generation 1 starts at 0x273a1000
generation 2 starts at 0x025b1000
ephemeral segment allocation context: none
segment begin allocated size
025b0000 025b1000 035aff50 0xffef50(167729448)
0ea00000 0ea01000 0f9ffd20 0xffed20(167723848)
19a20000 19a21000 1aa1fe54 0xffee54(167726928)
2a750000 2a751000 2b6fb10c 0xfaa10c(164252288)
263a0000 263a1000 26df1224 0xa50224(108139888)
273a0000 273a1000 274a4c70 0x103c70(10640488)
Large object heap starts at 0x035b1000
segment begin allocated size
035b0000 035b1000 04307138 0xd56138(139840568)
1dc60000 1dc61000 1e580050 0x91f050(95642408)
20490000 20491000 206cc878 0x23b878(23409848)
Total Size: Size: 0x63ab464 (104510564) bytes.
------------------------------
GC Heap Size: Size: 0x63ab46445 (1045105648) bytes.
还有 dumpheap 统计信息(它没有显示一个特定对象使用了所有内存,而是显示了很多对象(我的猜测)
05ef4e70 1615 516800 DevExpress.XtraEditors.ViewInfo.TextEditViewInfo
66418298 11091 763524 System.Windows.EffectiveValueEntry[]
7219a874 24397 780704 System.EventHandler
7219f680 10866 918152 System.Int32[]
6592dc98 9502 932360 System.Xaml.XamlNode[]
05ab1bf4 7180 1091360 DevExpress.Utils.AppearanceObject
05ffd498 2010 1101480 Infragistics.Win.UltraWinGrid.UltraGridColumn
72198390 19429 1165740 System.Reflection.RuntimeMethodInfo
721a12a4 4261 1199184 System.Collections.Hashtable+bucket[]
7219dc28 23649 1474820 System.Object[]
721a2518 13502 7978588 System.Byte[]
7219d834 237668 15219668 System.String
003aa9b0 45181 37740118 Free
Total 1282570 objects
Fragmented blocks larger than 0.5 MB:
Addr Size Followed by
2b3cc938 0.5MB 2b454220 DevExpress.Xpo.Helpers.ObjectRecord
2b454248 0.8MB 2b5295d8 DevExpress.Xpo.Helpers.ObjectRecord
2b6680b0 0.6MB 2b6f9e18 DevExpress.Utils.AppearanceObject
请注意,从上面的命令我 removed/edited 一些对象名称(因为它是公司特定的,但我认为你有整体的想法)
我们在会话和缓存中存储了大量数据,想检查一下为 asp.net 缓存和会话数据存储了多少数据。查看此内容的最佳方式是什么?
You can use the MEX.dll extension with Full memory dump and windbg.
然后您可以 运行 命令 AspNetCache -stats 和 AspNetCache -nosession
0:000> **!AspNetCache -stats**
# Items Type Name
======= =====================================================
15 ABC.Core.Services.Cache.NewDataCache
==trimmed============
Total Entries: 25
0:000> !AspNetCache -nosession
CacheItem: 0eca63dc
Key: 0ec9370c "rfq" [3] (System.String)
Value: 0ec93bf0 (App.Core.Services.Cache.NewDataCache)
CacheItem: 0eca6948
Key: 0ec93720 "contriInstrument" [16] (System.String)
Value: 0eca647c (App.Core.Services.Cache.ContriInstrumentCache)
CacheItem: 0eca6e5c
Key: 0ec93750 "alarmSetting" [12] (System.String)
Value: 0eca6990 (App.Core.Services.Cache.ContriInstruAlarmSettingCache)
CacheItem: 0eca7898
Key: 0ec93778 "contribAlarm" [12] (System.String)
Value: 0eca6ec0 (App.Core.Services.Cache.NewDataCache)
CacheItem: 0eca82c8
Key: 0ec937a0 "contribIndicator" [16] (System.String)
Value: 0eca78fc (App.Core.Services.Cache.NewDataCache)
然后你有 !DumpAspNetSession 命令,它将转储所有会话 details.here 的帮助
:000> !mex.dumpaspnetsession -?
!DumpAspNetSession - Prints information on ASP.NET InProc Sessions
Usage:
!DumpAspNetSession -id <sessionid>
-id <sessionid> : Displays detailed information for the session with the specified id
!DumpAspNetSession {-locked2 | -locked}
-locked2 : Alternate presentation for -locked
-locked : Displays all ASP.NET sessions that are polling for an exclusive lock
!DumpAspNetSession -ctx <httpContext>
-ctx <httpContext> : Displays detailed information for the session associated with an HttpContext
!DumpAspNetSession [<addr>]
addr : Displays detailed information for the specified session
!DumpAspNetSession
Displays all In-Proc ASP.NET sessions
!DumpAspNetSession [-?|-h]
-?|-h|-help : Display this help text