开发者

what does it mean when an object has no root using !gcroot with SOS?

开发者 https://www.devze.com 2023-03-10 03:11 出处:网络
I\'m tracking a memory leak where I\'m using !dumpheap -stat !dumpheap -mt !gcroot however !gcroot doesnt show anything,I\'ve been thinkin开发者_StackOverflow中文版g this means the object has no re

I'm tracking a memory leak where I'm using

!dumpheap -stat !dumpheap -mt !gcroot

however !gcroot doesnt show anything, I've been thinkin开发者_StackOverflow中文版g this means the object has no refs but hasnt been collected. but I'm not 100% confident.

0:018> !dumpheap -mt 000007fee15f0bb0     
         Address               MT     Size
000000001c87b570 000007fee15f0bb0  3145752     
000000001cb7b588 000007fee15f0bb0  3145752     
000000001e9675a8 000007fee15f0bb0  3145752     
000000001ec675c0 000007fee15f0bb0  3145752   


0:018> !gcroot 000000001ec675c0 
Note: Roots found on stacks may be false positives. Run "!help gcroot" for
more info.
Scan Thread 0 OSTHread 1eb4
Scan Thread 2 OSTHread 1c60
Scan Thread 4 OSTHread 1370
Scan Thread 6 OSTHread d5c
Scan Thread 7 OSTHread 740
Scan Thread 10 OSTHread 40c
Scan Thread 14 OSTHread 20d4
Scan Thread 15 OSTHread 398
Scan Thread 16 OSTHread 214c
Scan Thread 17 OSTHread 2538


Having no root means an object is unreachable.

When an object is not reachable, the garbage collector considers the object garbage, and can be collected.

An object having no root at some point in its lifetime is a normal occurance, in fact essential as to how garbage collection works.

Refs:

  • Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework

  • Garbage Collection

  • Garbage Collector Basics and Performance Hints

0

精彩评论

暂无评论...
验证码 换一张
取 消