Exemplo n.º 1
0
        public static MemoryDumpDataSet.JoinedMemoryDumpTableDataTable Join(MemoryDumpDataSet.MemoryDumpTableDataTable First, MemoryDumpDataSet.MemoryDumpTableDataTable Second)
        {
            DataSet JoinedSet = new DataSet();

            JoinedSet.Tables.Add(First);
            JoinedSet.Tables.Add(Second);
            JoinedSet.Relations.Add(new DataRelation("a", First.ClassNameColumn, Second.ClassNameColumn, false));

            MemoryDumpDataSet.JoinedMemoryDumpTableDataTable Result = new MemoryDumpDataSet.JoinedMemoryDumpTableDataTable();
            foreach (MemoryDumpDataSet.MemoryDumpTableRow Row in JoinedSet.Tables[First.TableName].Rows)
            {
                foreach (MemoryDumpDataSet.MemoryDumpTableRow ChildRow in Row.GetChildRows("a"))
                {
                    MemoryDumpDataSet.JoinedMemoryDumpTableRow ResultRow = Result.NewJoinedMemoryDumpTableRow();
                    ResultRow.ClassName1 = Row.ClassName;
                    ResultRow.Count1     = Row.Count;
                    ResultRow.MT1        = Row.MT;
                    ResultRow.TotalSize1 = Row.TotalSize;
                    ResultRow.DeltaCount = ChildRow.Count - Row.Count;
                    ResultRow.ClassName2 = ChildRow.ClassName;
                    ResultRow.Count2     = ChildRow.Count;
                    ResultRow.MT2        = ChildRow.MT;
                    ResultRow.TotalSize2 = ChildRow.TotalSize;

                    ResultRow.CountFactor = (double)(ResultRow.Count2) / ResultRow.Count1;

                    Result.Rows.Add(ResultRow);
                }
            }

            return(Result);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="MemoryDumpLines"></param>
        /// <param name="matchFilter">If returns true, only this entry will be used</param>
        /// <returns></returns>
        public static MemoryDumpDataSet.MemoryDumpTableDataTable ConvertMemoryDump(String Name, String[] MemoryDumpLines, Func <MemoryDumpDataSet.MemoryDumpTableRow, bool> matchFilter = null)
        {
            var errors = new List <string>();

            MemoryDumpDataSet.MemoryDumpTableDataTable Result = new MemoryDumpDataSet.MemoryDumpTableDataTable();
            Result.TableName = Name;

            foreach (String DumpLine in MemoryDumpLines)
            {
                if (string.IsNullOrEmpty(DumpLine))
                {
                    continue;
                }

                MemoryDumpDataSet.MemoryDumpTableRow ResultLine = Result.NewMemoryDumpTableRow();
                try
                {
                    ConvertMemoryDumpLine(DumpLine, ResultLine);
                }
                catch (Exception e)
                {
                    errors.Add(string.Format("Parsing line '{0}' failed with '{1}'", DumpLine, e.Message));
                    continue;
                }

                // Use matchFilter
                if (matchFilter != null && matchFilter(ResultLine) == false)
                {
                    continue;
                }


                Result.Rows.Add(ResultLine);
            }

            if (errors.Count > 0)
            {
                var finalErrors = errors;
                if (errors.Count > 100)
                {
                    MessageBox.Show("Too many errors generated, not all are shown");
                    finalErrors = errors.Take(10).ToList();
                }
                // this violates some patterns
                MessageBox.Show(string.Format("Errors in lines:{0}{1}", Environment.NewLine, string.Join(Environment.NewLine, finalErrors)));
            }
            return(Result);
        }
Exemplo n.º 3
0
        private void txtSecondDump_TextChanged(object sender, EventArgs e)
        {
            var msInterals = new List <string>
            {
                "System.",
                "MS.",
                "<CppImplementation",
                "Microsoft",
                "__type_info_node",
                "__DynamicallyInvokableAttribute",
                "<CrtImplementationDetails",
            };
            Func <MemoryDumpDataSet.MemoryDumpTableRow, bool> filter = s =>
            {
                // This is the early exist
                if (cbHideSystem.Checked && msInterals.Any(i => s.ClassName.Contains(i)))
                {
                    return(false);
                }
                // Use filter, case insensitive
                if (string.IsNullOrWhiteSpace(textBoxFilter.Text) == false && s.ClassName.IndexOf(textBoxFilter.Text, StringComparison.CurrentCultureIgnoreCase) == -1)
                {
                    return(false);
                }
                return(true);
            };

            try
            {
                MemoryDumpDataSet.MemoryDumpTableDataTable FirstDump  = MemoryComparerManager.ConvertMemoryDump("First", txtFirstDump.Lines, filter);
                MemoryDumpDataSet.MemoryDumpTableDataTable SecondDump = MemoryComparerManager.ConvertMemoryDump("Second", txtSecondDump.Lines, filter);

                Joined = MemoryComparerManager.Join(FirstDump, SecondDump);
                joinedMemoryDumpTableBindingSource.DataSource = Joined;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error occurred");
            }
        }