随笔 - 66  文章 - 0  评论 - 496  阅读 - 39万 
 
摘要: Web API入门指南有些朋友回复问了些安全方面的问题,这里尽量围绕着Web API的安全性来展开,介绍一些安全的基本概念,常见安全隐患、相关的防御技巧以及Web API提供的安全机制。 阅读全文
posted @ 2013-09-21 18:56 微软互联网开发支持 阅读(24442) 评论(50) 推荐(168) 编辑
 
摘要: 这篇文章中主要介绍Web API的主要作用以及与其他同类型框架的对比,最后通过一些相对复杂的实例展示如何通过Web API构建http服务,同时也展示了Visual Studio构建.net项目的各种强大。 阅读全文
posted @ 2013-09-07 08:42 微软互联网开发支持 阅读(74894) 评论(90) 推荐(213) 编辑
 
摘要: 你愿意为打开一个网页等待多长时间?我一秒也不愿意等。但是事实上大多数网站在响应速度方面都让人失望。现在越来越多的人开始建立自己的网站,博客,你的网页响应速度如何呢?在这篇文章中我们来介绍一下提高网页性能的最佳实践及相应问题的解决方案,让站长或者即将要成为站长的朋友了解如何去测试和提高网站响应速度,对自己的网站更有信心。 阅读全文
posted @ 2013-08-11 18:09 微软互联网开发支持 阅读(43875) 评论(90) 推荐(332) 编辑
  2015年4月2日

摘要 :

NetExt中有两个比较常用的命令可以用来分析heap上面的对象. 一个是!wheap, 另外一个是!windex.

!wheap 这个命令可以用于打印出heap structure信息. heap 上 object汇总后的信息. 这个命令也可以按照一些条件过滤出objects, 不过执行速度比较慢. 在这一点上, 更推荐!windex.
!windex是一个非常常用的命令. 这个命令可以用来查找heap上面实现某个interface, 继承某个abstract class 或者class的对象. 这个命令执行之后, 也会缓存做过index后的对象, 可以加快类似命令的之行速度. 同时也有非常酷炫的功能, 可以批量的从同一类型的object中显示出个别字段.

!wheap

!wheap 这个命令可以用于打印出heap structure信息. 以及heap object的汇总后的信息.  加上参数 –detailsonly, 正如他的名字一样, 可以打印出详细的信息.

它可以显示出的Heap的数量, 由于这个CLR RUTIME使用的GC Mode是Server Mode (1). 那么Heap的数量会根据Processor的数量有所不同. 这里能够看到Heap的数量是2个.

关于GC 类型的区别, 可以参考下面的链接

从输出结果可以看出来每个Managed Heap都有自己的一段地址. 如果Heap的size比较大, 还会包含多个Segment. 每个Segment的最大值都是固定的. 最大值值由很多因素决定. 不同的环境和配置时, 这个值会不一样. 当一个Segment将要分配满的时候, 会创建出一个新的Segment. 这个Segment 会缓慢增长, 直到长满为止.

这个命令也会提示GC Heap 上不同Generation代上的object的数量. 比较特别的是 Generation 3. 我们所认识的Generation 3. 


0:000> !wheap -detailsonly
Heaps: 2           <-- heap 的数量 --> 
Server Mode: 1   <-- GC Mode, 1表示是Server Mode --> 
Heap [0]:                <-- 第一个Heap -->
    Allocated: 0000000155a56fe8
    Card Table: 00000000027ea6b0
    Ephemeral Heap Segment: 0000000155660000
    Finalization Fill Pointers: 000000c28007cd40
    Heap Address: 0000000000e1e790
    Lowest Address: 0000000155660000
    Highest Address: 00000001f5660000
    Generation Addresses:
        [0]:AllocStart(0000000155793728),AllocCxtLimit(0000000000000000),AllocCtxPtr(0000000000000000),StartSeg(0000000155660000)
        [1]:AllocStart(0000000155660080),AllocCxtLimit(0000000000000000),AllocCtxPtr(0000000000000000),StartSeg(0000000155660000)
        [2]:AllocStart(0000000155660068),AllocCxtLimit(0000000000000000),AllocCtxPtr(0000000000000000),StartSeg(0000000155660000)
        [3]:AllocStart(00000001d5660068),AllocCxtLimit(0000000000000000),AllocCtxPtr(0000000000000000),StartSeg(00000001d5660000)

Segments:
Segment: 0000000155660000 Start: 0000000155660068 End: 0000000155981340 HiMark: 0000000155a56fe8 Committed: 0000000155a61000 Reserved: 0000000195660000 Next: 0000000000000000  <-- 第一个Segment, 由于有第二个Segment已经创建出来, 可以猜测这个Segment已经快分配完. 用End的地址减去Start的地址能够算出一个Segment的大小. 这里是64MB. -->
Segment: 00000001d5660000 Start: 00000001d5660068 End: 00000001d569bf10 HiMark: 00000001d569bf10 Committed: 00000001d56a1000 Reserved: 00000001e5660000 Next: 0000000000000000
Heap [1]:
    Allocated: 0000000195907af8
    Card Table: 00000000027ea6b0
    Ephemeral Heap Segment: 0000000195660000
    Finalization Fill Pointers: 000000c28007cd40
    Heap Address: 0000000000e20db0
    Lowest Address: 0000000155660000
    Highest Address: 00000001f5660000
    Generation Addresses:
        [0]:AllocStart(000000019573e270),AllocCxtLimit(0000000000000000),AllocCtxPtr(0000000000000000),StartSeg(0000000195660000)
        [1]:AllocStart(0000000195660080),AllocCxtLimit(0000000000000000),AllocCtxPtr(0000000000000000),StartSeg(0000000195660000)
        [2]:AllocStart(0000000195660068),AllocCxtLimit(0000000000000000),AllocCtxPtr(0000000000000000),StartSeg(0000000195660000)
        [3]:AllocStart(00000001e5660068),AllocCxtLimit(0000000000000000),AllocCtxPtr(0000000000000000),StartSeg(00000001e5660000)

Segments:
Segment: 0000000195660000 Start: 0000000195660068 End: 0000000195907af8 HiMark: 0000000195907af8 Committed: 0000000195911000 Reserved: 00000001d5660000 Next: 0000000000000000
Segment: 00000001e5660000 Start: 00000001e5660068 End: 00000001e5660080 HiMark: 00000001e5660080 Committed: 00000001e5661000 Reserved: 00000001f5660000 Next: 0000000000000000

Heap Areas:
Area [0000000155660068]: 0000000155660068-0000000155660080 (        24) Heap: 0 Generation: 2 Large: 0  <-- 表示 24个对象处于Generation 2 -->
Area [0000000155660080]: 0000000155660080-0000000155793728 (   1259176) Heap: 0 Generation: 1 Large: 0
Area [0000000155793728]: 0000000155793728-0000000155a61000 (   2939096) Heap: 0 Generation: 0 Large: 0
Area [0000000195660068]: 0000000195660068-0000000195660080 (        24) Heap: 1 Generation: 2 Large: 0
Area [0000000195660080]: 0000000195660080-000000019573e270 (    909808) Heap: 1 Generation: 1 Large: 0
Area [000000019573e270]: 000000019573e270-0000000195911000 (   1912208) Heap: 1 Generation: 0 Large: 0
Area [00000001d5660068]: 00000001d5660068-00000001d569bf10 (    245416) Heap: 0 Generation: 3 Large: 1  <-- 表示 245416个对象处于Generation 3, 即Large Object Heap -->
Area [00000001e5660068]: 00000001e5660068-00000001e5660080 (        24) Heap: 1 Generation: 3 Large: 1
0000000155660068 0000000000e111d0       24   0 2 Free
0000000155660080 0000000000e111d0       24   0 1 Free
0000000155660098 0000000000e111d0       24   0 1 Free
00000001556600b0 000007fef0b96cb8      160   0 1 System.Exception
0000000155660150 000007fef0b96f10      160   0 1 System.OutOfMemoryException
00000001556601f0 000007fef0b96f98      160   0 1 System.StackOverflowException
0000000155660290 000007fef0b97020      160   0 1 System.ExecutionEngineException
0000000155660330 000007fef0b970a8      160   0 1 System.Threading.ThreadAbortException
00000001556603d0 000007fef0b970a8      160   0 1 System.Threading.ThreadAbortException

.....
0000000195747da0 000007fee67a1e60       32   1 0 System.Xml.Schema.XmlSchemaObjectTable+ValuesCollection
0000000195747dc0 000007fee67a1f28       56   1 0 System.Xml.Schema.XmlSchemaObjectTable+XSOEnumerator
0000000195747df8 000007fef0b9c768       36   1 0 System.Int32[]
0000000195747e20 000007fee67a2048       96   1 0 System.Collections.Generic.Dictionary`2+Entry[[System.Xml.XmlQualifiedName, System.Xml],[System.Xml.Schema.XmlSchemaObject, System.Xml]][]
0000000195747e80 000007fee679fd20       88   1 0 System.Xml.Schema.XmlSchemaObjectTable+XmlSchemaObjectEntry[]
0000000195747ed8 000007fee67a1e60       32   1 0 System.Xml.Schema.XmlSchemaObjectTable+ValuesCollection
00000001d5660068 0000000000e111d0       24   0 3 Free
00000001d5660080 000007fef0b9adf8     8192   0 3 System.Object[]
.....

This output was throttled. Only the first 500 objects of each heap range has been shown.
Use -nothrottle to list all objects or any limiting parameter (-type for example)
View Code

- detailsonly 的目的是打印出来Heap的structure的信息. Object仅仅打印前500个. 如果要打印出的Heap上所有的对象, 则要使用参数 –nothrottle, 不过这一命令的运行时间会略长.

用-start 以及 –end 参数, 可以打印出一个范围内的object的数据.

用 –mt  <string>参数, 可以打印出指定的MethodTable值的objects. 类似于命令!gcheap –mt <addr>

 

!wheap的显示结果会统计出Heap上Object的一些汇总信息. 这些信息是按照对象类型进行分类, 一条数据表示一个对象类型.

第一列是其中一个object的地址, 如果有多个对象是相同类型, 仅仅显示第一个.

第二列是这个类型的对象的MethodTable的地址.

第三列是这个类型的总共使用了多少virtual memory. 在做high memory 的场景的CASE的情况下, 可以通过这个值快速找到占用virtual memory 最高的对象类型.

第四列是这个类型的数量.

第五列是这个类型的名称

 

!wheap

…….

0000000195747d18 000007fef0b9c768       36   1 0 System.Int32[]
0000000195747d40 000007fee679a850       96   1 0 System.Collections.Generic.Dictionary`2+Entry[[System.Xml.XmlQualifiedName, System.Xml],[System.Xml.Schema.SchemaAttDef, System.Xml]][]
0000000195747da0 000007fee67a1e60       32   1 0 System.Xml.Schema.XmlSchemaObjectTable+ValuesCollection
0000000195747dc0 000007fee67a1f28       56   1 0 System.Xml.Schema.XmlSchemaObjectTable+XSOEnumerator
0000000195747df8 000007fef0b9c768       36   1 0 System.Int32[]
0000000195747e20 000007fee67a2048       96   1 0 System.Collections.Generic.Dictionary`2+Entry[[System.Xml.XmlQualifiedName, System.Xml],[System.Xml.Schema.XmlSchemaObject, System.Xml]][]
0000000195747e80 000007fee679fd20       88   1 0 System.Xml.Schema.XmlSchemaObjectTable+XmlSchemaObjectEntry[]
0000000195747ed8 000007fee67a1e60       32   1 0 System.Xml.Schema.XmlSchemaObjectTable+ValuesCollection
View Code

 

!windex

!windex是一个非常常用的命令. 这个命令不但可以早heap中挖掘你所需要的某个类型的数据. 最有用处的地方是, 可以用来查找heap上面实现某个interface, 继承某个abstract class 或者class的对象. 这个命令执行之后, 也会缓存做过index后的对象, 可以加快类似命令的之行速度.

下面SHOW一下!windex比较有趣的功能, 通过WINDBG的UI将heap上个object展示成树形结构. 这样的做法比较形象的对各种对象进行分析.

首先在windbg中运行!windex -tree的命令. 这个命令会快速对heap上的object做index. 然后生成一个临时文件在本地. 同时也生成了一条命令.

 

0:000> !windex -tree
Starting indexing at 20:19:06 PM
Indexing finished at 20:19:07 PM
7,098,503 Bytes in 77,156 Objects
Index took 00:00:01
Copy, paste and run command below:
.cmdtree C:\Users\sonicguo\AppData\Local\Temp\HEAE0D6.tmp

image 

将这个命令COPY & PASTE 到命令行上执行. 然后会弹出另外一个窗口, 如下图.  这个图的效果已经非常有点接近Visual Studio中检查object的窗口效果了.

image

 

 

这个时候可以double click 某一条记录. 会显示出该条记录的详情.

0:000> !windex -mt 000007FEE79EFA20
Index is up to date
 If you believe it is not, use !windex -flush to force reindex
00000001556ebc68 000007fee79efa20 System.ServiceModel.BasicHttpBinding      112   0 1
00000001556f2b88 000007fee79efa20 System.ServiceModel.BasicHttpBinding      112   0 1

如果双击的不是这个类型, 而是该类型下面某一个field, 那么会显示出所有这个类型的每一个字段的值. 例如这里BasicHttpBinding有两个. 我想知道每一个BasicHttpBinding的name. 那么只要双击这个name, 就会把两个BasicHttpBinding的名字都打印出来.

这个方式非常适合快速调查某一个类型的特定字段的值.

image

0:000> .foreach({$addr} {!windex -short -mt 000007FEE79EFA20}){.echo Address: {$addr}; !wselect name from {$addr}}
Address: 00000001556ebc68
[System.ServiceModel.BasicHttpBinding]
System.String name = 00000001556ccbd8 wsHttpBindingConfiguration
Address: 00000001556f2b88
[System.ServiceModel.BasicHttpBinding]
System.String name = 00000001556ce118 basicHttpBindingConfigurationJava

 

 

!windex 还支持模糊查询. 例如, 执行下面这个命令就可以把所有后缀为BasicHttpBinding的对象都打印出来.

0:000> !windex -type *.BasicHttpBinding
Index is up to date
 If you believe it is not, use !windex -flush to force reindex
00000001556ebc68 000007fee79efa20 System.ServiceModel.BasicHttpBinding      112   0 1
00000001556f2b88 000007fee79efa20 System.ServiceModel.BasicHttpBinding      112   0 1

 

配合 !wfrom 来使用, 可以从过滤出来的对象中找到某一个指定的字段, 前提是要知道字段名称.

0:000> !wfrom -type *.BasicHttpBinding select name
name: wsHttpBindingConfiguration
name: basicHttpBindingConfigurationJava

2 Object(s) listed

 

这个显示结果虽然很爽, 但是没有能够看到对象的地址, 略微不足. 为了弥补这个不足, 可以使用额外的参数 $addr() 来解决.

0:000> !wfrom -type *.BasicHttpBinding select $addr(),name
calculated: 00000001556EBC68
name: wsHttpBindingConfiguration
calculated: 00000001556F2B88
name: basicHttpBindingConfigurationJava

 

不仅如此, 还可以用$a()的参数来添加别名, 使得输出结果可读性更强.

0:000> !wfrom -type *.BasicHttpBinding select $a("Address",$addr()), $typename(), name
Address: 00000001556EBC68
calculated: System.ServiceModel.BasicHttpBinding
name: wsHttpBindingConfiguration
Address: 00000001556F2B88
calculated: System.ServiceModel.BasicHttpBinding
name: basicHttpBindingConfigurationJava

2 Object(s) listed


这么多的新功能, 是否觉得酷炫吊炸天呢? 下一期, 我会继续介绍更多酷炫的新功能.

Sonic Guo

posted @ 2015-04-02 21:27 微软互联网开发支持 阅读(1032) 评论(1) 推荐(4) 编辑
  2015年3月16日
摘要: 本章节介绍NetExt常用的命令. 并且对SOS进行一些对比. 阅读全文
posted @ 2015-03-16 14:03 微软互联网开发支持 阅读(1564) 评论(0) 推荐(1) 编辑
  2015年3月10日
摘要: 在使用WINDBG做debugging的时候,需要一个好的工具帮助进行数据分析. 最常见的extension包括SOS, PSSCOR. NetExt则是另外一种提供了丰富命令功能的debugging extension. NetExt主要用于Managed Code的分析功能, 对ASP.NET, WCF, WIF有良好的支持, 并且提供了很多常用的分析命令. 它涵盖了SOS以及PSSCOR的绝大部分命令, 并且提供了更为强大的数据挖掘的功能. 在这个系列里面, 我将一一介绍这个功能. 阅读全文
posted @ 2015-03-10 00:18 微软互联网开发支持 阅读(2443) 评论(11) 推荐(3) 编辑
  2015年2月10日
摘要: 最近遇到了一个奇怪的 WCF 安全配置问题, WCF Service 上面配置了Windows Authentication. IIS上也启用了 Windows Authentication, 但是仍然出现IIS没有启用Windows Authentication的问题. 在网络上能查到的资料很少. 通过自己的troubleshooting发现所遇到的错误提示比较具有迷惑性. 所以POST上来给大家分享一下. 阅读全文
posted @ 2015-02-10 21:55 微软互联网开发支持 阅读(1096) 评论(0) 推荐(1) 编辑
  2015年1月9日
摘要: 最近在博客园里面看到有人在讨论 C# String的一些特性. 大部分情况下是从CODING的角度来讨论String. 本人觉得非常好奇, 在运行时态, String是如何与这些特性联系上的. 本文将侧重在通过WinDBG来观察String在进程内的布局, 以此来解释C# String的一些特性. 阅读全文
posted @ 2015-01-09 00:15 微软互联网开发支持 阅读(9058) 评论(25) 推荐(32) 编辑
  2014年12月30日
摘要: 对Microsoft Azure 网站而言, 用户能控制的主要是自身应用的数据和文件, 而服务器系统或其他更底层的配置对我们来说像个黑盒。 这本是基于PAAS的设计,因为这样我们可以将重点放在应用上而不用担心底层平台。也许有时候难免有些好奇:要是想多了解一些Microsoft Azure网站所在的“服务器”也完全不可能吗?本文将给大家做个简单的介绍。 阅读全文
posted @ 2014-12-30 11:20 微软互联网开发支持 阅读(1000) 评论(0) 推荐(1) 编辑
  2014年12月15日
摘要: 在 IE11 中,我们重头开始重建 F12 工具。它们具有全新的 UI 和新功能性,可使你更快、更轻松地进行开发和调试。使用 F12 开发人员工具,你可以调试、测试网页并加快其速度。无论你是需要微调你的 CSS 布局还是查找内存泄漏,你都能在此处找到帮助工具。 阅读全文
posted @ 2014-12-15 09:08 微软互联网开发支持 阅读(3807) 评论(1) 推荐(8) 编辑
  2014年12月11日
摘要: 摘要 : 从IIS 7 开始, IIS增加了对非HTTP协议的支持. 因此, 自IIS 7之后, 可以将NetTcpBinding等非HTTP协议的Bindings直接寄宿在IIS上面. 本文将介绍如何在IIS上配置WCF NetTcpBinding, 并且对其工作的方式进行比较深入的讨论. 阅读全文
posted @ 2014-12-11 22:14 微软互联网开发支持 阅读(1891) 评论(1) 推荐(2) 编辑
  2014年12月10日
摘要: Compat Inspector是一个基于JavaScript的,用于快速分析网站在新版本Internet Explorer中兼容性问题的,自动化扫描工具。 阅读全文
posted @ 2014-12-10 15:16 微软互联网开发支持 阅读(1802) 评论(0) 推荐(0) 编辑
摘要: 代理自动配置(Proxy auto-config,简称PAC) 是一种网页浏览器技术,用于定义浏览器该如何自动选择适当的代理服务器来访问一个网址。本文介绍如何配置自动代理。 阅读全文
posted @ 2014-12-10 15:07 微软互联网开发支持 阅读(3237) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示