开发者

WinDbg - how can I tell if an object is around in memory but waiting to be garbage collected

开发者 https://www.devze.com 2023-01-29 07:08 出处:网络
I\'m new to WinDbg and have started using it this week to diagnose memory leaks in an ASP.NET 4 application. I took a memory dump of an active IIS process and am trying to determine which items are ok

I'm new to WinDbg and have started using it this week to diagnose memory leaks in an ASP.NET 4 application. I took a memory dump of an active IIS process and am trying to determine which items are ok to still be in memory and which are not. For example, I see several System.Web.UI objects in memory, and a single ASPX page. I get a list of all the objects and their addresses, then run the following command...

!gcroot [addr]

...but end up with similar results each time...

0:000> !gcroot 1112f704
Note: Roots found on stacks may be false positives.
Run "!help gcroot" for more info.
Scan Thread 11 OSTHread e14
Scan Thread 29 OSTHread 2590
Scan Thread 31 OSTHread 65c
Scan Thread 32 OSTHread 2180
Scan Thread 33 OSTHread a18
Scan Thread 10 OSTHread 404
Scan Thread 35 OSTHread 12ec
Scan Thread 19 OSTHread a54
Scan Thread 3 OSTHread 251c
Scan Thread 37 OSTHread dfc
Scan Thread 38 OSTHread 1720
Scan Thread 39 OSTHread 24a8
Scan Thread 40 OSTHread 26a8
Scan Thr开发者_JS百科ead 41 OSTHread 2784
Scan Thread 42 OSTHread 1a24
Scan Thread 44 OSTHread 1fc8
Scan Thread 45 OSTHread 15f8
Scan Thread 47 OSTHread 2394
Scan Thread 48 OSTHread 1638

Is this indicative of an object that is still in memory but waiting to be GCed? Most of the objects that concern me (those UI elements that should be disposed of after the page is rendered and sent to the client) seem to have no root that I can find.

Any suggestions or clarifications?


Yes. If the !gcroot command returns no roots for an object then it is simply in memory waiting to be collected. I believe it's possible there is still a WeakReference to still be holding onto the object though so there is the potential it will be re-rooted at a future point. But at the point of the !gcroot command it's elligable for collection.

0

精彩评论

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