Exemplo n.º 1
0
        //=========================================
        // timer1_Tick
        //=========================================
        private void timer1_Tick(object sender, EventArgs e)
        {
            int numHeaps = AllocStats.getNumHeaps();

            //ask the manager what our heap sizes are.
            for (int i = 0; i < numHeaps; i++)
            {
                HeapAlloc pHeap = AllocStats.getHeapFromIndex(i);

                uint allocSize = pHeap.getTotalAllocatedBytes();
                //covert the Y value to megabytes for graphing.
                int yMB = (int)(allocSize / (1024 * 1024));
                fastTimeLine.addPointToLine(pHeap.getMemPtr(), (int)yMB);
            }


            //elapsed time
            TimeSpan deltaTime = DateTime.Now - mStartTime;

            label2.Text = "Time Line [" + deltaTime.Hours + ":" + deltaTime.Minutes + ":" + deltaTime.Seconds + "]";

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


            fastTimeLine.Refresh();
        }
Exemplo n.º 2
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());
            }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 //=========================================
 // HeapAllocStats
 //=========================================
 public HeapAllocNode(HeapAlloc ownerAlloc)
 {
     mpOwnerAlloc = ownerAlloc;
     this.Text    = mpOwnerAlloc.getName() + " : " + MemoryNumber.convert(mpOwnerAlloc.getTotalAllocatedBytes());
 }