Example #1
0
        void listBox_Leaks_SelectedIndexChanged(object sender, EventArgs e)
        {
            Leak leak = listBox_Leaks.SelectedItem as Leak;

            if (leak != null)
            {
                textBox_CallStack.Text = leak.CallStack;
            }
        }
Example #2
0
        private async void button_ParseHeapLeak_Click(object sender, EventArgs e)
        {
            string logPath = textBox_WindbgLogPath.Text;

            if (!File.Exists(logPath))
            {
                MessageBox.Show("Please specify the windbg log file!", "Error!");
                return;
            }
            m_Leaks.Clear();
            listBox_Leaks.Items.Clear();
            m_Leaks = await Task <List <Leak> > .Factory.StartNew(() =>
            {
                List <Leak> leaks = new List <Leak>();
                Leak currentLeak  = null;
                using (StreamReader sr = new StreamReader(logPath))
                {
                    while (!sr.EndOfStream)
                    {
                        string line = sr.ReadLine();

                        Match leakMatch = s_LeakHeader.Match(line);
                        if (leakMatch.Success)
                        {
                            if (currentLeak != null)
                            {
                                addNewLeak(leaks, currentLeak);
                            }
                            currentLeak = new Leak(leakMatch.Groups[1].ToString(), leakMatch.Groups[2].ToString());
                            continue;
                        }

                        Match stackMatch = s_CallStack.Match(line);
                        if (stackMatch.Success && currentLeak != null)
                        {
                            currentLeak.AppendCallStack(stackMatch.Groups[1].ToString());
                        }
                    }
                }
                addNewLeak(leaks, currentLeak);
                return(leaks);
            });

            textBox_Total.Text     = m_Total.ToString("#,###0");
            textBox_TotalSize.Text = m_Totalsize.ToString("#,###0");
            m_Leaks.Sort(Leak.CompareByTotalSize);
            listBox_Leaks.Items.AddRange(m_Leaks.ToArray());
        }
Example #3
0
        private void addNewLeak(List <Leak> leaks, Leak currentLeak)
        {
            m_Total     += 1;
            m_Totalsize += currentLeak.TotalSize;
            bool found = false;

            foreach (var leak in leaks)
            {
                if (!string.IsNullOrEmpty(leak.CallStack) && leak.CallStack.Equals(currentLeak.CallStack))
                {
                    found = true;
                    leak.AddCount();
                }
            }
            if (!found)
            {
                leaks.Add(currentLeak);
            }
        }
Example #4
0
 public static int CompareByTotalSize(Leak x, Leak y)
 {
     return(y.TotalSize.CompareTo(x.TotalSize));
 }
Example #5
0
 public static int CompareByCount(Leak x, Leak y)
 {
     return(y.Count.CompareTo(x.Count));
 }
Example #6
0
 public static int CompareBySize(Leak x, Leak y)
 {
     return(y.Size.CompareTo(x.Size));
 }