Example #1
0
            public void update()
            {
                Hashtable pLines = mpOwnerAlloc.getLineAllocations();

                if (!Expanded)
                {
                    this.Nodes.Clear();
                    if (pLines.Count > 0)
                    {
                        Nodes.Add(new GDITreeViewNode());
                    }
                }
                else
                {
                    this.Nodes.Clear();

                    ////////////////// //per line
                    IDictionaryEnumerator line_enumerator = pLines.GetEnumerator();
                    while (line_enumerator.MoveNext())
                    {
                        LineAlloc la = ((LineAlloc)line_enumerator.Value);

                        if (la != null)
                        {
                            LineAllocNode lan = new LineAllocNode(la);

                            addNode(lan);
                        }
                    }
                }
                this.Text = MemoryNumber.convert(mpOwnerAlloc.getTotalAllocatedBytes(false)) + "\t" + mpOwnerAlloc.getFilename();
            }
Example #2
0
        //=========================================
        // load
        //=========================================
        public bool load(uint lineNum, Hashtable BlockAllocs)
        {
            this.Text = " line :" + lineNum;

            //
            IDictionaryEnumerator _enumerator = BlockAllocs.GetEnumerator();

            while (_enumerator.MoveNext())
            {
                BlockAlloc block = (BlockAlloc)_enumerator.Value;


                SymbolInfo.LookupInfo li = new SymbolInfo.LookupInfo();

                string callstack = "";
                string spacing   = "";
                for (int i = block.mContext.mBackTraceSize - 1; i >= 0; i--)
                {
                    HaloWarsMem.getSymbolInfo().lookupImmediate(block.mContext.mBackTrace[i], ref li);

                    string shortName = Path.GetFileName(li.mFilename);
                    if (HaloWarsMem.getSymbolInfo().isIgnoreSymbol(shortName))
                    {
                        continue;
                    }

                    string displayString = "";
                    if (shortName == "?")
                    {
                        displayString = "unkown (..)";
                    }
                    else
                    {
                        displayString = shortName + "::" + li.mSymbol + " (line " + li.mLine + ") \n";
                    }
                    listBox1.Items.Add(spacing + displayString);

                    //if (lastNode != null)
                    //   lastNode = lastNode.Nodes.Add(displayString);
                    //else
                    //   lastNode = tv.Nodes.Add(displayString);

                    spacing += " ";
                }

                listBox1.Items.Add(" (" + MemoryNumber.convert(block.mBlockSize) + ")");


                listBox1.Items.Add("==========================================================");
                listBox1.Items.Add("==========================================================");
            }

            return(true);
        }
Example #3
0
            //=========================================
            // update
            //=========================================
            public uint update()
            {
                uint totalBytes = 0;

                int numheaps = AllocStats.getNumHeaps();

                for (int i = 0; i < numheaps; i++)
                {
                    HeapAlloc pHeap = AllocStats.getHeapFromIndex(i);

                    IDictionaryEnumerator _enumerator = pHeap.getFileAllocations().GetEnumerator();
                    while (_enumerator.MoveNext())
                    {
                        FileAlloc fa        = ((FileAlloc)_enumerator.Value);
                        string    longFName = fa.getFilename();

                        if (longFName.Contains("xbox\\code"))
                        {
                            string trimedFName = giveTrimmedString(longFName);
                            if (trimedFName.ToLower() == mFilename.ToLower())
                            {
                                totalBytes += fa.getTotalAllocatedBytes(false);
                            }
                        }
                        else
                        {
                            if (longFName.ToLower() == mFilename.ToLower())
                            {
                                totalBytes += fa.getTotalAllocatedBytes(false);
                            }
                        }
                    }
                }

                if (totalBytes > mMaxAllocatedBytes)
                {
                    mMaxAllocatedBytes = totalBytes;
                }

                mCurrAllocatedBytes = totalBytes;

                this.Text = Path.GetFileName(mFilename) + ", curr :  " + MemoryNumber.convert(totalBytes) + " , max : " + MemoryNumber.convert(mMaxAllocatedBytes);


                return(totalBytes);
            }
Example #4
0
        //=========================================
        // timer1_Tick
        //=========================================
        private void timer1_Tick(object sender, EventArgs e)
        {
            uint mTotalAllocatedBytesI = 0;
            uint mTotalAllocatedBytesE = 0;

            int numHeaps = AllocStats.getNumHeaps();

            for (int i = 0; i < numHeaps; i++)
            {
                HeapAlloc pHeap = AllocStats.getHeapFromIndex(i);

                Hashtable             pHeapFiles      = pHeap.getFileAllocations();
                IDictionaryEnumerator file_enumerator = pHeapFiles.GetEnumerator();
                while (file_enumerator.MoveNext())
                {
                    FileAlloc fa      = ((FileAlloc)file_enumerator.Value);
                    string    trFName = giveTrimmedString(fa.getFilename());
                    if (trFName.ToLower() == mTruncatedFilePath.ToLower())
                    {
                        mTotalAllocatedBytesE += fa.getTotalAllocatedBytes(false);
                        mTotalAllocatedBytesI += fa.getTotalAllocatedBytes(true);
                    }
                }
            }

            //covert the Y value to megabytes for graphing.
            uint allocSize = mTotalAllocatedBytesE;
            int  yMB       = (int)(allocSize / (1024 * 1024));

            mTimeline.addPointToLine(0xBEEFCAD0, (int)yMB);

            if (mScrollerStuck)
            {
                mTimeline.setScrollPercent(1);
            }


            mTimeline.Refresh();

            FilenameLabel.Text = mFilenameOnly + " i(" + MemoryNumber.convert(mTotalAllocatedBytesI) + ")" + " e(" + MemoryNumber.convert(mTotalAllocatedBytesE) + ")";
        }
Example #5
0
        //=========================================
        // render
        //=========================================
        protected override void OnPaint(PaintEventArgs e)
        {
            ///////////////////////////////
            Graphics g = e.Graphics;

            int[] xTabs = { 5, 270, 360, 450 };

            int x        = 0;
            int y        = 0;
            int ySpacing = 12;

            /////////////////////
            //print header..
            g.DrawString("name", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_DimGray, xTabs[0], y);
            g.DrawString("exclusive", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_DimGray, xTabs[1], y);
            y += ySpacing;
            g.DrawLine(GDIStatic.Pen_DimGray, 0, y, Width, y);
            y += 2;


            ////////////////////
            //Draw BG Bars
            for (int i = 0; i < mLastSortedKeys.Count; i++)
            {
                Brush BGBrush = i % 2 == 0 ? GDIStatic.SolidBrush_CommonBGColor : GDIStatic.SolidBrush_DimGray;
                g.FillRectangle(BGBrush, 0, y + (i * ySpacing + 2), Width, ySpacing);
            }

            /////////////////////
            //print sorted list..
            for (int i = mLastSortedKeys.Count - 1; i >= 0; i--)
            {
                string filename       = mLastSortedKeys[i].mFilenameOnly;
                UInt64 exclusiveTotal = mLastSortedKeys[i].mTotalAllocatedBytes;
                int    list_index     = mLastSortedKeys.Count - 1 - i;
                g.DrawString(list_index + ": " + filename, GDIStatic.Font_Console_10, GDIStatic.SolidBrush_Black, xTabs[0], y);
                g.DrawString(MemoryNumber.convert((uint)exclusiveTotal), GDIStatic.Font_Console_10, GDIStatic.SolidBrush_Black, xTabs[1], y);
                y += ySpacing;
            }
        }
Example #6
0
            //=========================================
            // update
            //=========================================
            public void update()
            {
                uint totalBytes = 0;

                for (int i = 0; i < this.Nodes.Count; i++)
                {
                    if (this.Nodes[i] is GroupFileNode)
                    {
                        GroupFileNode pNode = (GroupFileNode)this.Nodes[i];
                        totalBytes += pNode.update();
                    }
                }

                if (totalBytes > mMaxAllocatedBytes)
                {
                    mMaxAllocatedBytes = totalBytes;
                }

                mCurrAllocatedBytes = totalBytes;

                this.Text = mGroupName + ", curr :  " + MemoryNumber.convert(totalBytes) + " , max : " + MemoryNumber.convert(mMaxAllocatedBytes);
            }
Example #7
0
        //=========================================
        // load
        //=========================================
        public bool load(string filename, TopAllocators.FileAllocStats fas)
        {
            if (filename == "?")
            {
                return(false);
            }

            if (!fileExistsCheck(ref filename))
            {
                return(false);
            }



            //////////////////////////////////////////////////////
            //EVERYTHING IS OK! LOAD THE FILE!
            System.IO.StreamReader sr = null;
            try
            {
                sr = new StreamReader(File.Open(filename, FileMode.Open, FileAccess.Read));
                if (sr == null)
                {
                    MessageBox.Show(null, "Error Loading file :" + filename, "error", MessageBoxButtons.OK);
                    return(false);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.InnerException.ToString());
            }


            //generate line statistics
            Hashtable    lineStats          = buildLineStats(fas);//KEY is LINENUM, VALUE is ALLOCAMOUNT
            List <Point> highlightStartLens = new List <Point>();
            //load the file to our list box
            int lineCount = 0;

            while (!sr.EndOfStream)
            {
                string strFromFile = sr.ReadLine();
                if (!strFromFile.Contains("\n"))
                {
                    strFromFile += "\n";
                }


                //if this line has memory allocations, mark it with the amount, and highlight it.
                if (lineStats.Contains(lineCount))
                {
                    uint   memAmt       = (uint)lineStats[lineCount];
                    string memoryAmount = MemoryNumber.convert(memAmt);

                    int startCharIndex = richTextBox1.Text.Length;
                    richTextBox1.Text += memoryAmount + "\t" + strFromFile;
                    int selLength = richTextBox1.Text.Length - startCharIndex;

                    highlightStartLens.Add(new Point(startCharIndex, selLength));
                }
                else
                {
                    richTextBox1.Text += "\t" + strFromFile;
                }
                lineCount++;
            }

            sr.Close();


            //we have to wait until our entire file is read in before we can highlight...
            for (int i = 0; i < highlightStartLens.Count; i++)
            {
                richTextBox1.Select(highlightStartLens[i].X, highlightStartLens[i].Y);
                richTextBox1.SelectionBackColor = Color.Pink;
            }


            //move us back to the top
            jumpToLineIndex(0);


            this.Text = "Memory Allocation View : " + filename;
            return(true);
        }
Example #8
0
        //=========================================
        // OnPaint
        //=========================================
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            int[] xTabs = { 5, 100, 170, 250, 330, 420, 510 };

            int x        = 0;
            int y        = 0;
            int ySpacing = 12;


            g.DrawString("allocated", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_DimGray, xTabs[1], y);
            g.DrawString("blocks", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_DimGray, xTabs[2], y);
            g.DrawString("N", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_DimGray, xTabs[3], y);
            g.DrawString("D", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_DimGray, xTabs[4], y);
            g.DrawString("R", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_DimGray, xTabs[5], y);

            y += ySpacing + 1;

            g.DrawLine(GDIStatic.Pen_DimGray, 0, y, Width, y);

            y += 2;

            //SORT THE LIST!
            List <int> sortOrder = new List <int>();

            for (int i = 0; i < AllocStats.getNumHeaps(); i++)
            {
                sortOrder.Add(i);
            }

            //SORT!
            for (int i = 0; i < AllocStats.getNumHeaps(); i++)
            {
                for (int j = 0; j < AllocStats.getNumHeaps(); j++)
                {
                    uint target = AllocStats.getHeapFromIndex(sortOrder[i]).getTotalAllocatedBytes();
                    uint next   = AllocStats.getHeapFromIndex(sortOrder[j]).getTotalAllocatedBytes();
                    if (next < target)
                    {
                        int tmp = sortOrder[i];
                        sortOrder[i] = sortOrder[j];
                        sortOrder[j] = tmp;
                    }
                }
            }



            uint totalActiveBytes  = 0;
            uint totalActiveBlocks = 0;

            for (int i = 0; i < AllocStats.getNumHeaps(); i++)
            {
                HeapAlloc pHeap = AllocStats.getHeapFromIndex(sortOrder[i]);
                Brush     brush = new SolidBrush(pHeap.ColorVal);

                uint totalNumBlocks = pHeap.getTotalNumAllocations();
                uint totalNumBytes  = pHeap.getTotalAllocatedBytes();


                g.DrawString(pHeap.getName() + " :", GDIStatic.Font_Console_10, brush, xTabs[0], y);
                g.DrawString(MemoryNumber.convert(totalNumBytes), GDIStatic.Font_Console_10, brush, xTabs[1], y);
                g.DrawString(totalNumBlocks.ToString(), GDIStatic.Font_Console_10, brush, xTabs[2], y);
                g.DrawString(pHeap.getNumNews().ToString(), GDIStatic.Font_Console_10, brush, xTabs[3], y);
                g.DrawString(pHeap.getNumDeletes().ToString(), GDIStatic.Font_Console_10, brush, xTabs[4], y);
                g.DrawString(pHeap.getNumResizes().ToString(), GDIStatic.Font_Console_10, brush, xTabs[5], y);

                g.FillRectangle(brush, x + 0, y + 2, 4, 8);

                y += ySpacing;

                totalActiveBlocks += totalNumBlocks;
                totalActiveBytes  += totalNumBytes;
            }


            g.DrawString("Total :", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_White, xTabs[0], y + ySpacing);
            g.DrawString(MemoryNumber.convert(totalActiveBytes), GDIStatic.Font_Console_10, GDIStatic.SolidBrush_White, xTabs[1], y + ySpacing);
            g.DrawString(totalActiveBlocks.ToString(), GDIStatic.Font_Console_10, GDIStatic.SolidBrush_White, xTabs[2], y + ySpacing);
        }
Example #9
0
            //=========================================
            // update
            //=========================================
            public void update()
            {
                Hashtable pFiles = mpOwnerAlloc.getFileAllocations();

                if (Expanded)
                {
                    //do a quick pass to determine if we need to remove stuff..
                    for (int i = 0; i < Nodes.Count; i++)
                    {
                        if (Nodes[i] is FileAllocNode)
                        {
                            FileAllocNode fan = (FileAllocNode)Nodes[i];
                            if (!pFiles.Contains(fan.mpOwnerAlloc.getFilename()))
                            {
                                Nodes.RemoveAt(i);
                                i--;
                            }
                        }
                        else
                        {
                            Nodes.RemoveAt(i);
                            i--;
                        }
                    }

                    //our local node list should be completly present in the parent container.
                    IDictionaryEnumerator file_enumerator = pFiles.GetEnumerator();
                    while (file_enumerator.MoveNext())
                    {
                        FileAlloc fa = ((FileAlloc)file_enumerator.Value);

                        bool found = false;
                        for (int i = 0; i < Nodes.Count; i++)
                        {
                            FileAllocNode fan = (FileAllocNode)Nodes[i];
                            if (fan.mpOwnerAlloc == fa)
                            {
                                fan.update();
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            if (fa.getTotalAllocatedBytes(false) == 0)
                            {
                                continue;
                            }
                            FileAllocNode fan = new FileAllocNode(fa);
                            addNode(fan);
                        }
                    }
                }
                else
                {
                    Nodes.Clear();
                    if (pFiles.Count > 0)
                    {
                        Nodes.Add(new GDITreeViewNode());
                    }
                }

                this.Text = mpOwnerAlloc.getName() + " : " + MemoryNumber.convert(mpOwnerAlloc.getTotalAllocatedBytes());
            }
Example #10
0
 //=========================================
 // HeapAllocStats
 //=========================================
 public HeapAllocNode(HeapAlloc ownerAlloc)
 {
     mpOwnerAlloc = ownerAlloc;
     this.Text    = mpOwnerAlloc.getName() + " : " + MemoryNumber.convert(mpOwnerAlloc.getTotalAllocatedBytes());
 }
Example #11
0
            //=========================================
            // FileAllocStats
            //=========================================
            public FileAllocNode(FileAlloc ownerAlloc)
            {
                mpOwnerAlloc = ownerAlloc;

                this.Text = MemoryNumber.convert(mpOwnerAlloc.getTotalAllocatedBytes(false)) + "\t" + mpOwnerAlloc.getFilename();
            }
Example #12
0
 public LineAllocNode(LineAlloc ownerAlloc)
 {
     mpOwnerAlloc = ownerAlloc;
     this.Text    = MemoryNumber.convert(mpOwnerAlloc.getTotalAllocatedBytes()) + " from " + mpOwnerAlloc.getTotalNumAllocations() + " allocations at Line " + mpOwnerAlloc.getLinenum();
 }