首页 > 其他分享 >WinDbg实操一(查看.net对象)

WinDbg实操一(查看.net对象)

时间:2024-04-07 12:44:07浏览次数:16  
标签:12 WinDbg 011d4ebc ObjectGc System Demo1 Collections 实操 net

查看.net对象

测试代码
 
using System;
using System.Collections.Generic;

namespace Demo1_ObjectGc
{
internal class Program
{
private static List _values = new List();
static void Main(string[] args)
{
for(int i = 0;i< 10000;i++)
{
_values.Add(new A() { ValueB = new B { Value = i} });
}
Console.WriteLine("运行结束,请开始分析");
Console.ReadLine();
}
}
public class A
{
public B ValueB { get; set; }
}
public class B
{
public int Value { get; set; }
}
}

0:006> .load C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
0:006> .load C:\Windows\Microsoft.NET\Framework\v4.0.30319\SOS.dll
0:006> .loadby sos clr
0:006> .load D:\WinDbgEx\SOSEx\x86\sosex.dll
查看堆中的对象类型和大小
0:006> !DumpHeap -stat
Statistics:
      MT    Count    TotalSize Class Name
7b3cd594        1           12 System.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib]]
7b3ccabc        1           12 System.Security.HostSecurityManager
7b3cc050        1           12 System.Collections.Generic.ObjectEqualityComparer`1[[System.Type, mscorlib]]
7b3cca40        1           16 System.Security.Policy.Evidence+EvidenceLockHolder
7b3c9fd8        1           16 System.Security.Policy.AssemblyEvidenceFactory
7b38d8b8        1           16 System.IO.TextReader+SyncTextReader
7b3c9f20        1           20 Microsoft.Win32.SafeHandles.SafePEFileHandle
7b3612f4        1           20 System.IO.Stream+NullStream
7b360ecc        1           20 Microsoft.Win32.SafeHandles.SafeFileMappingHandle
7b360e7c        1           20 Microsoft.Win32.SafeHandles.SafeViewOfFileHandle
7b360de8        1           20 System.Text.InternalEncoderBestFitFallback
7b3cd28c        1           24 System.Version
7b360fa8        1           24 System.IO.TextWriter+SyncTextWriter
7b360e38        1           24 System.Text.InternalDecoderBestFitFallback
011d4f0c        1           24 System.Collections.Generic.List`1[[Demo1_ObjectGc.A, Demo1_ObjectGc]]
7b3cceb4        1           28 System.Text.UTF8Encoding+UTF8EncodingSealed
7b3caeec        1           28 System.SharedStatics
7b38f4c8        1           28 System.Text.DBCSCodePageEncoding+DBCSDecoder
7b3610e4        1           28 Microsoft.Win32.Win32Native+InputRecord
7b360a94        1           28 System.Text.EncoderNLS
7b3ccd54        2           32 System.Text.DecoderReplacementFallback
7b3ccd04        2           32 System.Text.EncoderReplacementFallback
7b3ccb30        1           32 System.Text.UnicodeEncoding
7b3c9f80        1           32 System.Security.Policy.PEFileEvidenceFactory
7b3cb60c        1           36 System.Security.PermissionSet
7b3cce28        2           40 Microsoft.Win32.SafeHandles.SafeFileHandle
7b3cb588        1           40 System.Security.Policy.Evidence
7b3cc91c        1           44 System.Threading.ReaderWriterLock
7b3676d4        1           44 System.Text.InternalEncoderBestFitFallbackBuffer
7b3cd3cc        1           48 System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Globalization.CultureData, mscorlib]]
7b3cd044        1           48 System.Collections.Hashtable+bucket[]
7b3cc54c        4           48 System.Int32
7b3cb760        1           48 System.Collections.Generic.Dictionary`2[[System.Type, mscorlib],[System.Security.Policy.EvidenceTypeDescriptor, mscorlib]]
7b3c9e80        4           48 System.UInt16
7b3ccff4        1           52 System.Collections.Hashtable
7b3cc098        1           52 System.Type[]
7b3cb52c        1           52 System.Threading.Thread
7b3cd378        2           56 System.Text.StringBuilder
7b3cc964        2           56 System.Reflection.RuntimeAssembly
7b36113c        2           56 System.IO.__ConsoleStream
7b3cdab4        1           60 System.IO.StreamWriter
7b3cd6c8        1           60 System.Collections.Generic.Dictionary`2+Entry[[System.String, mscorlib],[System.Globalization.CultureData, mscorlib]][]
7b3d33ac        1           64 System.IO.StreamReader
7b3cb2b0        1           68 System.AppDomainSetup
7b3cd0d4        1           72 System.IO.UnmanagedMemoryStream
7b38f93c        1           76 System.Text.DBCSCodePageEncoding
7b3cd338        1           84 System.Globalization.CalendarData
7b3cadd4        1           84 System.ExecutionEngineException
7b3cad90        1           84 System.StackOverflowException
7b3cad48        1           84 System.OutOfMemoryException
7b3cacf4        1           84 System.Exception
7b3cae50        8           96 System.Object
7b3cd2f4        1          104 System.Globalization.CalendarData[]
7b3caf2c        1          112 System.AppDomain
7b3cd80c        1          132 System.Globalization.NumberFormatInfo
7b3cd1a0        2          144 System.Globalization.CultureInfo
7b3cae18        2          168 System.Threading.ThreadAbortException
012f7338       44          456      Free
7b3cc778        3          468 System.Collections.Generic.Dictionary`2+Entry[[System.Type, mscorlib],[System.Security.Policy.EvidenceTypeDescriptor, mscorlib]][]
7b3cc510       11          564 System.Int32[]
7b3cb490       18          608 System.String[]
7b3cd258        2          616 System.Globalization.CultureData
7b3cbc4c       26          728 System.RuntimeType
7b3cdd04        3          806 System.Byte[]
7b3cb37c       10         2984 System.Char[]
7b3cac04      166         5606 System.String
7b3caea4        6        18016 System.Object[]
011d5400    10000       120000 Demo1_ObjectGc.B
011d4ebc    10000       120000 Demo1_ObjectGc.A
011d5300       14       131224 Demo1_ObjectGc.A[]
Total 20381 objects
根据类型查找存活对象
0:006> !DumpHeap -live -mt 011d4ebc
 Address       MT     Size
030e23fc 011d4ebc       12     
030e2430 011d4ebc       12     
030e2448 011d4ebc       12     
0313ce38 011d4ebc       12     
0313ce50 011d4ebc       12     
0313ce68 011d4ebc       12     
0313ce80 011d4ebc       12     
0313ce98 011d4ebc       12     
0313ceb0 011d4ebc       12     
0313cec8 011d4ebc       12     
0313cee0 011d4ebc       12     
0313cef8 011d4ebc       12     
0313cf10 011d4ebc       12     
0313cf28 011d4ebc       12     
0313cf40 011d4ebc       12     
0313cf58 011d4ebc       12     
0313cf70 011d4ebc       12     
0313cf88 011d4ebc       12     

Statistics:
      MT    Count    TotalSize Class Name
011d4ebc    10000       120000 Demo1_ObjectGc.A
Total 10000 objects
查看某个对象找出GCRoot
0:006> !GCRoot 0313cf88
HandleTable:
    011b13ec (pinned handle)
    -> 040e3670 System.Object[]
    -> 030e23b4 System.Collections.Generic.List`1[[Demo1_ObjectGc.A, Demo1_ObjectGc]]
    -> 031225f0 Demo1_ObjectGc.A[]
    -> 0313cf88 Demo1_ObjectGc.A

Found 1 unique roots (run '!GCRoot -all' to see all roots).
查看对象
0:006> !DumpObj 0313cf88
Name:        Demo1_ObjectGc.A
MethodTable: 011d4ebc
EEClass:     011d1344
Size:        12(0xc) bytes
File:        E:\workspcace\WinDbg\WinDbgStudy\Demo1_ObjectGc\bin\Debug\Demo1_ObjectGc.exe
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
011d5400  4000002        4     Demo1_ObjectGc.B  0 instance 0313cf94 <ValueB>k__BackingField

0:006> !do 0313cf94 
Name:        Demo1_ObjectGc.B
MethodTable: 011d5400
EEClass:     011d14c8
Size:        12(0xc) bytes
File:        E:\workspcace\WinDbg\WinDbgStudy\Demo1_ObjectGc\bin\Debug\Demo1_ObjectGc.exe
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
7b3cc54c  4000003        4         System.Int32  1 instance     9999 <Value>k__BackingField

标签:12,WinDbg,011d4ebc,ObjectGc,System,Demo1,Collections,实操,net
From: https://www.cnblogs.com/leafroc/p/18118813

相关文章

  • 构筑智能未来的开源 .Net AI知识库/智能体项目
        在这个信息爆炸的时代,我们如何快速准确地从汪洋大海的数据中抽取真正有价值的知识呢?AntSK,一个基于.NET开发的人工智能知识库和智能体项目,似乎给出了一个新颖的答案。今天,就让我们一起深入了解AntSK项目,探索它如何帮助我们更高效地处理信息和知识。 项目进展   ......
  • Pdfium.Net.Free 一个免费的Pdfium的 .net包装器--可视化编辑pdf
    Pdfium.Net.Free支持.NETFramework4.0.NETFramework4.5.NETStandard2.0.Net8.0可以和PdfiumViewer.Free共同使用预览pdf,也可以直接引用Pdfium.Net.Free操作pdf,解决部分.NetCore调用的问题,Pdfium.Net.Free封装了现有Pdfium的函数,实现了部分操作pdf的功能,部分功......
  • ASP.NET中button、linkbutton、imagebutton及hyperlink这四个控件之间的功能区别?
    原文链接:https://blog.csdn.net/weixin_45763353/article/details/118005453Button是按钮控件,具有按钮所有的属性和事件方法,在客户端被渲染为表单元素提交按钮。Linkbutton是链接按钮,用于创建超链接样式的按钮。该控件的外观与HyperLink控件相同,但其功能与Button控件一样。它......
  • ILSpy是一个开源的.NET反编译器
    在软件开发领域,反编译器是一种强大的工具,它允许开发者查看已编译代码的内部结构。对于.NET平台,ILSpy是一款备受欢迎的反编译器,它能够将已编译的.NET程序集(如DLL或EXE文件)转换回近似的C#或VB.NET源代码。这不仅有助于理解第三方库的工作原理,还能在调试、优化或学习他人代码时提供巨......
  • JetBrains Rider 2024.1 (macOS, Linux, Windows) - 快速且强大的跨平台 .NET IDE
    JetBrainsRider2024.1(macOS,Linux,Windows)-快速且强大的跨平台.NETIDE请访问原文链接:JetBrainsRider2024.1(macOS,Linux,Windows)-快速且强大的跨平台.NETIDE,查看最新版。原创作品,转载请保留出处。作者主页:sysin.orgJetBrainsRider-快速且强大的跨平台......
  • .net学生选课系统功能操作说明
    ​学生选课系统分为三种用户角色登录,管理员,教师,学生操作,系统配置完成后,首先使用管理员账号密码登录默认是admin 密码admin1234登录成功后左侧可以看到管理员可以管理院系信息,专业管理,教师管理,学生管理,课程管理五大板块,分别可以对其进行增删改查操作,按照功能顺序,我们需......
  • Replication Controller、ReplicaSet和Deployment(Kubernetes调度系列,结合操作命令讲解
    目录一、概述二、ReplicationController2.1ReplicationController说明2.2ReplicationController举例三、ReplicaSet3.1ReplicaSet说明3.2ReplicaSet举例四、无状态应用管理Deployment4.1概述4.2创建Deployment4.2.1Deployment标签内容解析4.2.2ku......
  • 在Keycloak中实现多租户并在ASP.NET Core下进行验证
    Keycloak是一个功能强大的开源身份和访问管理系统,提供了一整套解决方案,包括用户认证、单点登录(SSO)、身份联合、用户注册、用户管理、角色映射、多因素认证和访问控制等。它广泛应用于企业和云服务,可以简化和统一不同应用程序和服务的安全管理,支持自托管或云部署,适用于需要安全、灵......
  • 对比.Net平台下三大日志库:Serilog、log4net和NLog
    原文链接:Serilog,log4netandNLogComparison:LoggingLibrariesfor.NETApplications(bytehide.com)译者前言:最近在搭建一套自己用的后端开发的架构,涉及到日志系统的选型,一番检索下找到了这篇文章,还算比较新,翻译过来跟大家分享一下。这篇文章运用了大量的比喻,不知道各位是......
  • YOLOv8 深度解析!一文看懂,快速上手实操(附实践代码)
    https://zhuanlan.zhihu.com/p/679179913 计算机视觉研究院主要涉及AI研究和落地实践,主要致力于目标检测、目标跟踪、图像分割、OCR、模型量化、模型部署等研究方向。研究院每日分享最新的论文算法新框架,提供论文一键下载,并分享实战项目。研究院主要着重”技术研究“和“实践落......