gpt4 book ai didi

.net - 如何确定对象被固定的原因

转载 作者:行者123 更新时间:2023-12-04 14:36:46 26 4
gpt4 key购买 nike

我试图追踪为什么我的应用程序中的某些对象被固定。到目前为止我看到的对象是对象数组!gcroot 显示数组被固定,但我不知道如何找出它被固定的原因。

输出:

0:000> !dumpobj 0239cea0
Name: System.Object[]
MethodTable: 793041d0
EEClass: 790eda54
Size: 528(0x210) bytes
Array: Rank 1, Number of elements 128, Type CLASS
Element Type: System.Object
Fields:
None

0:000> !gcroot 0239cea0
Note: Roots found on stacks may be false positives. Run "!help gcroot" for
more info.
Scan Thread 0 OSTHread f3c
Scan Thread 2 OSTHread e54
Scan Thread 4 OSTHread 748
Scan Thread 5 OSTHread fe0
Scan Thread 7 OSTHread 7a0
Scan Thread 9 OSTHread cf4
Scan Thread 10 OSTHread a6c
Scan Thread 11 OSTHread bc4
Scan Thread 12 OSTHread 598
Scan Thread 13 OSTHread a8
Scan Thread 14 OSTHread 50c
Scan Thread 15 OSTHread ba4
Scan Thread 16 OSTHread b40
Scan Thread 17 OSTHread 534
Scan Thread 18 OSTHread 5fc
Scan Thread 19 OSTHread dfc
Scan Thread 20 OSTHread cc4
Scan Thread 21 OSTHread f84
Scan Thread 22 OSTHread 9f4
Scan Thread 23 OSTHread ff0
Scan Thread 24 OSTHread fb0
Scan Thread 25 OSTHread c14
Scan Thread 29 OSTHread 5c4
DOMAIN(0015EB90):HANDLE(Pinned):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(WeakSh):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(WeakSh):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(WeakSh):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(WeakSh):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(WeakSh):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(WeakSh):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(WeakSh):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])
DOMAIN(0015EB90):HANDLE(Unknwn):971e74:Root:0239cea0(System.Object[])

编辑:添加 !eeheap -gc 输出
!eeheap -gc
Number of GC Heaps: 1
generation 0 starts at 0x49a6f940
generation 1 starts at 0x49a0c8a8
generation 2 starts at 0x01301000
ephemeral segment allocation context: none
segment begin allocated size
01300000 01301000 022f05a0 0x00fef5a0(16709024)
0d0d0000 0d0d1000 0e0bb0cc 0x00fea0cc(16687308)
0e9e0000 0e9e1000 0f9de3e8 0x00ffd3e8(16765928)
11020000 11021000 12014808 0x00ff3808(16726024)
15020000 15021000 15ff3958 0x00fd2958(16591192)
139f0000 139f1000 1499f584 0x00fae584(16442756)
16020000 16021000 16fd7c30 0x00fb6c30(16477232)
19020000 19021000 1a013df4 0x00ff2df4(16723444)
17020000 17021000 17fcfe8c 0x00faee8c(16445068)
18020000 18021000 18fedb84 0x00fccb84(16567172)
1a020000 1a021000 1afc8814 0x00fa7814(16414740)
26010000 26011000 26f97d2c 0x00f86d2c(16280876)
2d010000 2d011000 2df97210 0x00f86210(16278032)
20010000 20011000 210028e0 0x00ff18e0(16718048)
21010000 21011000 220085d8 0x00ff75d8(16741848)
23810000 23811000 247acf60 0x00f9bf60(16367456)
28010000 28011000 28f84f80 0x00f73f80(16203648)
1c010000 1c011000 1cfba544 0x00fa9544(16422212)
1d010000 1d011000 1dfdcf64 0x00fcbf64(16564068)
32010000 32011000 32f9189c 0x00f8089c(16255132)
1e010000 1e011000 1eff9824 0x00fe8824(16680996)
2c010000 2c011000 2cfd4904 0x00fc3904(16529668)
300a0000 300a1000 3104a488 0x00fa9488(16422024)
24810000 24811000 2571bd20 0x00f0ad20(15772960)
36d10000 36d11000 37c982d4 0x00f872d4(16282324)
29010000 29011000 29fc96a0 0x00fb86a0(16484000)
27010000 27011000 27ee38bc 0x00ed28bc(15542460)
2a010000 2a011000 2afab094 0x00f9a094(16359572)
441c0000 441c1000 45149df0 0x00f88df0(16289264)
38d10000 38d11000 39ce4254 0x00fd3254(16593492)
3bd10000 3bd11000 3cc7a750 0x00f69750(16160592)
3ad10000 3ad11000 3bc8b878 0x00f7a878(16230520)
411c0000 411c1000 421655a0 0x00fa45a0(16401824)
2b010000 2b011000 2bfafae4 0x00f9eae4(16378596)
461c0000 461c1000 471a1bb0 0x00fe0bb0(16649136)
3e1c0000 3e1c1000 3f11151c 0x00f5051c(16057628)
34010000 34011000 35003ae4 0x00ff2ae4(16722660)
451c0000 451c1000 4609e680 0x00edd680(15586944)
4c1c0000 4c1c1000 4d105324 0x00f44324(16007972)
2f0a0000 2f0a1000 3007989c 0x00fd889c(16615580)
50e10000 50e11000 51cf17d8 0x00ee07d8(15599576)
33010000 33011000 34005d88 0x00ff4d88(16731528)
37d10000 37d11000 38cc6d7c 0x00fb5d7c(16473468)
481c0000 481c1000 4898a468 0x007c9468(8164456)
39d10000 39d11000 3acbe2d8 0x00fad2d8(16437976)
3f1c0000 3f1c1000 3fd1f378 0x00b5e378(11920248)
51e10000 51e11000 52e01018 0x00ff0018(16711704)
431c0000 431c1000 441805d8 0x00fbf5d8(16512472)
401c0000 401c1000 4116b2b0 0x00faa2b0(16425648)
421c0000 421c1000 430da254 0x00f19254(15831636)
491c0000 491c1000 49b98e0c 0x009d7e0c(10321420)
Large object heap starts at 0x02301000
segment begin allocated size
02300000 02301000 02f1bf20 0x00c1af20(12693280)
Total Size 0x31786160(829972832)
------------------------------
GC Heap Size 0x31786160(829972832)

最佳答案

GCRoot 通常不会告诉您为什么固定某些内容。您在 CLR 中找到的许多对象数组都用于内部事物。相反,阅读您对另一个答案的评论,我可以建议您首先从不同的东西开始来追踪您的内存泄漏吗?

从“!dumpheap -stat”开始,看看那里最大的内存用户。但是,忽略基本的 CLR 类型,例如 object[]、string 等。查找存在的对象(定义为“不是 mscorlib 或 system.dll 中的某些内容”),并找出它们的根源。通常更容易从那个方向追踪泄漏,即使事实证明您正在泄漏应用程序中的原始类型。

这通常是我在 CLR 中跟踪托管泄漏的方式,并且它对于大多数泄漏都相当有效。

关于.net - 如何确定对象被固定的原因,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1562500/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com