我想在大型應用程序中調試內存泄漏。我的第一步是熟悉WinDBG。我在.NET下面的程序:.NET - WinDBG - 字符串的內容
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Dim HelloWorld As String = "HelloWorld"
Dim testInt As Integer
Me.Show()
For testInt = 0 To 1000000
TextBox1.Text = testInt 'There is a textbox on the form
Application.DoEvents() 'So textbox updates on the fly
Next
Catch ex As Exception
End Try
End Sub
我試圖查看WinDbg中的HelloWorld的變量,它應該是「HelloWorld」的內容。我遵循這些指示:
1)將WinDBG附加到可執行文件並啓動調試器。
2)立即中斷(循環完成之前)
3)loadby SOS CLR
4)〜0
5)!clrstack
6)!dumpheap型的WinDBG(該項目名爲WinDBGApplication)
輸出是這樣的:
Statistics:
MT Count TotalSize Class Name
00186f88 1 12 WinDBGTest.My.MyProject+ThreadSafeObjectProvider`1[[WinDBGTest.My.MyProject+MyWebServices, WinDBGTest]]
00186e80 1 12 WinDBGTest.My.MyProject+ThreadSafeObjectProvider`1[[WinDBGTest.My.MyProject+MyForms, WinDBGTest]]
00186e2c 1 12 WinDBGTest.My.MyProject+MyForms
00186d3c 1 12 WinDBGTest.My.MyProject+ThreadSafeObjectProvider`1[[Microsoft.VisualBasic.ApplicationServices.User, Microsoft.VisualBasic]]
00186cec 1 12 WinDBGTest.My.MyProject+ThreadSafeObjectProvider`1[[WinDBGTest.My.MyComputer, WinDBGTest]]
00186be8 1 12 WinDBGTest.My.MyProject+ThreadSafeObjectProvider`1[[WinDBGTest.My.MyApplication, WinDBGTest]]
00184bf4 1 104 WinDBGTest.My.MyApplication
00187308 1 328 WinDBGTest.Form1
Total 8 objects
沒有證據表明一個名爲HelloWorld的字符串,並且基於對低級調試的有限理解,應該有。我究竟做錯了什麼?
我已經試過什麼被Rockstart建議,並得到如下的輸出:
OS Thread Id: 0x7a0 (0)
ESP/REG Object Name
0039E5EC 0234db94 System.Windows.Forms.Control+ControlNativeWindow
0039E63C 0234dadc System.Windows.Forms.TextBox
0039E658 0234dadc System.Windows.Forms.TextBox
0039E668 0234dadc System.Windows.Forms.TextBox
0039E680 0234db94 System.Windows.Forms.Control+ControlNativeWindow
0039E698 0234db94 System.Windows.Forms.Control+ControlNativeWindow
0039E6A8 0234db94 System.Windows.Forms.Control+ControlNativeWindow
0039E7FC 0234dadc System.Windows.Forms.TextBox
0039E864 02604b10 System.Windows.Forms.Control+MultithreadSafeCallScope
0039E868 02604b68 System.String 26309
0039E878 026049a8 System.String 26310
0039E87C 0234dadc System.Windows.Forms.TextBox
0039E880 026049a8 System.String 26310
0039E884 0234db94 System.Windows.Forms.Control+ControlNativeWindow
0039E890 0234db94 System.Windows.Forms.Control+ControlNativeWindow
0039E8A0 026049a8 System.String 26310
0039E8AC 0234dadc System.Windows.Forms.TextBox
0039E8B4 0234db84 System.Windows.Forms.PropertyStore
0039E8C8 0234dadc System.Windows.Forms.TextBox
0039E8CC 026049a8 System.String 26310
0039E8DC 026049a8 System.String 26310
0039E8E0 0234dadc System.Windows.Forms.TextBox
0039E8EC 0234dadc System.Windows.Forms.TextBox
0039E8F0 0234dadc System.Windows.Forms.TextBox
0039E904 0234d4e4 WinDBGTest.Form1
0039E940 0234d4e4 WinDBGTest.Form1
0039E944 0234e4c0 System.EventHandler
0039E970 0234a1c4 System.EventArgs
0039E978 0234d4e4 WinDBGTest.Form1
0039E9DC 0234d4e4 WinDBGTest.Form1
0039EA00 0234d4e4 WinDBGTest.Form1
0039EAE0 0234d984 System.Windows.Forms.Control+ControlNativeWindow
0039ED28 0234d4e4 WinDBGTest.Form1
0039ED34 0234d4e4 WinDBGTest.Form1
0039ED3C 0234d4e4 WinDBGTest.Form1
0039ED44 0234d4e4 WinDBGTest.Form1
0039ED4C 0234d4e4 WinDBGTest.Form1
0039EDCC 0234d4e4 WinDBGTest.Form1
0039EE18 023491c8 System.Windows.Forms.Application+ThreadContext
0039EE58 023490c8 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase+WinFormsAppContext
0039EE8C 02348f54 WinDBGTest.My.MyApplication
0039EEA8 02348f54 WinDBGTest.My.MyApplication
0039EEB8 02348f54 WinDBGTest.My.MyApplication
0039F1D8 02348640 System.Object[] (System.String[])
這不是完全不可能的,但windbg是排除泄漏故障的一個非常糟糕的工具。它可以幫助你避免淹沒數據,噪聲信號比非常低。改用.NET內存分析器。 – 2012-03-25 16:56:40
我同意,但WinDbg是免費的。你知道命令,我可以嘗試查看此字符串的內容? – w0051977 2012-03-25 17:10:41