-
Recent Posts
Recent Comments
Mr WordPress on Hello world! zhi on 《Windows用户态程序高效排错》 中涉及到的链接(ZT) Amanda on 歌颂祖国,我们不差钱 Eternal on 歌颂祖国,我们不差钱 Eternal on English Reading:关于中国成为世界第二的真相 Archives
- May 2017
- April 2017
- July 2016
- June 2016
- April 2015
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- August 2005
- July 2005
Categories
Meta
Monthly Archives: September 2008
使用!dump系列命令剖析ArrayList的内容
参考:!dumpheap –stat explained… (debugging .net leaks) by Tess 例程如下:[STAThread] static void Main(string[] args) { ArrayList list = new ArrayList(); list.Add("ItemA"); list.Add("ItemB"); Console.ReadLine(); } 运行程序,然后用WinDBG attach进程(F6) 加载SOS .loadby sos mscorwks 0:003>!dupmheap -stattotal 2212 objectsStatistics: MT Count TotalSize … Continue reading
Posted in Debug
Leave a comment
在Visual Studio中使用SOS
1.在要调试的Project的属性页上进行设置,选中"Enable unmanaged debugging"功能 否则加载SOS时会报错:".load sos’: not available while Managed only debugging." 2.在"Immediate Window"(Ctrl+Alt+I)中执行命令"!load sos"或".load sos"加载SOS Immediate Window支持很多用于Debug的高级命令,比如显示线程,调用栈的信息,见MSDN http://msdn.microsoft.com/en-us/library/f177hahy.aspx
Posted in Debug
Leave a comment
OutOfMemoryExceptions while remoting very large datasets(From Tess) 笔记
http://blogs.msdn.com/tess/archive/2008/09/02/outofmemoryexceptions-while-remoting-very-large-datasets.aspx 如果需要在Process和App Domain之间传递对象,需要把对象序列化后才能传递,序列化操作即耗费CPU又耗费内存,如果对象过于庞大和复杂,比如dataset,还会导致OOM(out of memory),此时用~* e !clrstack 会看到…0454f408 651eadee System.Data.DataSet.SerializeDataSet(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext, System.Data.SerializationFormat) 传递dataset的做法值得检讨:为什么要传递dataset?是否仅dataset中的一小部分需要传递?是否使用64bit系统可以解决问题? 通过Debug一个server-client结构的remoting例程来说明问题: 用windbg attach到remoting server进程上,执行 .loadby sos mscorwks 加载SOS, 显示mscorwks!WKS::gc_heap::allocate_large_object()的地址:0:008> x mscorwks!WKS*allocate_large*79ef212d mscorwks!WKS::gc_heap::allocate_large_object = <no type information> 在mscorwks!WKS::gc_heap::allocate_large_object()上加断点:0:008> bp 79ef212d " ?@ebx;!clrstack;g"在每次为大对象分配内存时都可以得到要分配的内存的大小,本例中,为了XML序列化100M的对象,使用了1G的内存! 解决方案:使用ds.RemotingFormat = SerializationFormat.Binary;
Posted in Debug
Leave a comment
APS.NET Memory Issue (From Tess) 笔记
http://blogs.msdn.com/tess/archive/2008/09/12/asp-net-memory-issues-high-memory-usage-with-ajaxpro.aspx 1. !dumpheap -state 显示托管堆中的内容,发现有大量的UI相关的对象和数据相关的对象.猜测: 如果有User control被放入session或cache或使用static对象,这个User control就一直不会被垃圾回收,而它的Parent属性引用的web page,以及web page上的其他control和control中的数据对象也都会一直存在,直到那个罪魁user control被移出session或cache. 2. !dumpheap -type *aspx 把托管堆中的所有web page对象显示出来,有1230个,正常情况下,每个页面对应一个正在执行的请求.用~* e !clrstack 列出所有线程的callstacks.没有一个正在处理请求.这说明page应该被回收而没有被回收. 3. !gcroot 6d67cb28 显示地址为6d67cb28的page对象的引用(或root)信息Root: 0a629ac8(System.Object[])-> 02777208(System.Collections.Specialized.HybridDictionary)-> 06946578(System.Collections.Hashtable)-> 3eac4e0c(System.Collections.Hashtable+bucket[])-> 6d67cb28(ASP.default_aspx)问题:System.Collections.Hashtable+bucket[]是什么对象?和System.Collections.Hashtable有什么关系?用reflector查看System.Collections.Hashtable的代码,得知bucket是Hashtable的嵌套类型private struct bucket { public object key; public object val; … Continue reading
Posted in Debug
Leave a comment
WinDBG 使用技巧2则
1. 为dmp文件添加Context menu,方便加载(From Tess)用reg文件生成context menu启动debugger,加载dmp文件,并传入一个包含参数的txt文件来进行必要的设置,比如:设置sympath,加载SOS,执行下文中的.cmdtree Reg 文件 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\.dmp]@="Debugger.Dump" [HKEY_CLASSES_ROOT\Debugger.Dump] [HKEY_CLASSES_ROOT\Debugger.Dump\DefaultIcon]@="c:\\debuggers\\cdb.exe" [HKEY_CLASSES_ROOT\Debugger.Dump\Shell] [HKEY_CLASSES_ROOT\Debugger.Dump\Shell\Debug_Without_Remote]@="Debug This Dump" [HKEY_CLASSES_ROOT\Debugger.Dump\Shell\Debug_Without_Remote\Command]@="\"C:\\debuggers\\windbg\" -z \"%1\" -c \"$<c:\\debuggers\\commands.txt\"" [HKEY_CLASSES_ROOT\Debugger.Dump\Shell\Debug_With_Remote70]@="Debug this Dump With Remote:70" [HKEY_CLASSES_ROOT\Debugger.Dump\Shell\Debug_With_Remote70\Command]@="\"C:\\debuggers\\windbg\" -server tcp:port=70 -z \"%1\" -c \"$<c:\\debuggers\\commands.txt\"" -z DumpFile 指定要加载的dump文件-c 在debugger启动时,执行一些命令,和$< … Continue reading
Posted in Debug
Leave a comment
下载狂
找书比读完这本书更吸引我,立贴为证. 寻找 Framework Design guidelines 2ed 搞到 2008.09.16 O’Reilly.C.Sharp.3.0.Design.Patterns.pdf 差 O’Reilly.Programming.C.Sharp.3.0.5th.Edition.pdf OReilly.Programming.dot.NET.3.5.Aug.2008.pdf 2008.09.17 Pro JavaScript Techniques.pdf Framework Design Guidelines … Continue reading
Posted in Books
Leave a comment
Debug the Process Memory Usage
1. Windows 内存管理 Reserve: The virtual memory space reserved for the application but no disk or main memory pages have been used. Commit: The physical memory for which space has been reserved on the disk paging file Working … Continue reading
Windows Task Manager 有关Process的信息
Image Name: 进程的名字 PID : 进程ID CPU Usage: 从前一次更新算起, 当前进程使用的CPU时间的百分比 CPU Time: 从进程开始运行算起,共使用了多少秒的CPU时间Memory Usage: In Task Manager, the current working set of a process, in kilobytes. The current working set is the number of pages currently resident in memory. On … Continue reading
Posted in Debug
Leave a comment