Exemplo n.º 1
0
            static void PrintCategories(MemoryCategory categoryList, double total, bool majorCategory)
            {
                ArrayList al = new ArrayList();

                for (MemoryCategory mc = categoryList; mc != null; mc = mc.nextCategory)
                {
                    al.Add(mc);
                }
                al.Sort();
                foreach (MemoryCategory mc in al)
                {
                    string format = ": {1,7:n0} kB ={2,5:f1}%  ({3,3:f1}% Private)";
                    if (majorCategory)
                    {
                        format = "{0,-30}" + format;
                        Console.WriteLine();
                    }
                    else
                    {
                        format = "  {0,-28}" + format;
                    }

                    Console.WriteLine(format, mc.categoryName, mc.presentSize / 1024, mc.presentSize / total * 100, mc.privateSize / mc.presentSize * 100.0);

                    if (mc.subCategories != null)
                    {
                        PrintCategories(mc.subCategories, total, false);
                    }
                }
            }
Exemplo n.º 2
0
            static MemoryCategory AddPage(MemoryCategory root, string categoryName, string subCategoryName, bool privatePage)
            {
                MemoryCategory mc;

                for (mc = root; mc != null; mc = mc.nextCategory)
                {
                    if (mc.categoryName == categoryName)
                    {
                        break;
                    }
                }
                if (mc == null)
                {
                    mc = new MemoryCategory();
                    mc.nextCategory = root;
                    root            = mc;
                    mc.categoryName = categoryName;
                }
                mc.presentSize += pageSize;
                if (privatePage)
                {
                    mc.privateSize += pageSize;
                }
                if (subCategoryName != null)
                {
                    mc.subCategories = AddPage(mc.subCategories, subCategoryName, null, privatePage);
                }
                return(root);
            }
 private static void RecomputeDeviceSettings()
 {
     if (!EmulateMobileDevice())
     {
         s_os            = OSCategory.PC;
         s_input         = InputCategory.Mouse;
         s_screen        = ScreenCategory.PC;
         s_screenDensity = ScreenDensityCategory.High;
         s_os            = OSCategory.PC;
         int systemMemorySize = SystemInfo.systemMemorySize;
         if (systemMemorySize < 500)
         {
             Debug.LogWarning("Low Memory Warning: Device has only " + systemMemorySize + "MBs of system memory");
             s_memory = MemoryCategory.Low;
         }
         else if (systemMemorySize < 0x3e8)
         {
             s_memory = MemoryCategory.Low;
         }
         else if (systemMemorySize < 0x5dc)
         {
             s_memory = MemoryCategory.Medium;
         }
         else
         {
             s_memory = MemoryCategory.High;
         }
     }
 }
Exemplo n.º 4
0
            int IComparable.CompareTo(Object thatObject)
            {
                MemoryCategory that = (MemoryCategory)thatObject;

                if (this.presentSize > that.presentSize)
                {
                    return(-1);
                }
                else if (this.presentSize < that.presentSize)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
    private T GetMemorySetting(MemoryCategory memory)
    {
        switch (memory)
        {
        case MemoryCategory.Low:
            if (!this.LowMemorySetting.WasSet)
            {
                break;
            }
            return(this.LowMemory);

        case MemoryCategory.Medium:
            return(!this.MediumMemorySetting.WasSet ? this.GetMemorySetting(MemoryCategory.Low) : this.MediumMemory);

        case MemoryCategory.High:
            return(!this.HighMemorySetting.WasSet ? this.GetMemorySetting(MemoryCategory.Medium) : this.HighMemory);
        }
        Debug.LogError("Could not find memory dependent value");
        return(default(T));
    }
 private static void RecomputeDeviceSettings()
 {
     if (PlatformSettings.EmulateMobileDevice())
       return;
     PlatformSettings.s_os = OSCategory.PC;
     PlatformSettings.s_input = InputCategory.Mouse;
     PlatformSettings.s_screen = ScreenCategory.PC;
     PlatformSettings.s_screenDensity = ScreenDensityCategory.High;
     PlatformSettings.s_os = OSCategory.PC;
     int systemMemorySize = SystemInfo.systemMemorySize;
     if (systemMemorySize < 500)
     {
       Debug.LogWarning((object) ("Low Memory Warning: Device has only " + (object) systemMemorySize + "MBs of system memory"));
       PlatformSettings.s_memory = MemoryCategory.Low;
     }
     else if (systemMemorySize < 1000)
       PlatformSettings.s_memory = MemoryCategory.Low;
     else if (systemMemorySize < 1500)
       PlatformSettings.s_memory = MemoryCategory.Medium;
     else
       PlatformSettings.s_memory = MemoryCategory.High;
 }
Exemplo n.º 7
0
        static void RunVadump(Process p)
        {
            ProcessStartInfo processStartInfo = new ProcessStartInfo("vadump.exe");

            processStartInfo.Arguments = "-o -p " + p.Id;

            processStartInfo.UseShellExecute = false;

            processStartInfo.RedirectStandardOutput = true;

            Process vadumpProcess = Process.Start(processStartInfo);

            //			vadumpProcess.WaitForExit();

            IntPtr processHandle = OpenProcess(0x1F0FFF, false, p.Id);

            GcRegion.InitGcRegions(processHandle);

            StreamReader r = vadumpProcess.StandardOutput;
            string       line;

            MemoryCategory.categoryList = null;

            while ((line = r.ReadLine()) != null)
            {
                string[] fields = line.Split(' ');
                if (fields.Length >= 3 &&
                    fields[0].IndexOf("0x") == 0 &&
                    fields[1].Length >= 3 && fields[1][0] == '(')
                {
                    bool privatePage = fields[1] == "(0)";
                    switch (fields[2])
                    {
                    case    "PRIVATE":
                        IntPtr addr = (IntPtr)Int64.Parse(fields[0].Substring(2), NumberStyles.HexNumber);
                        if (GcRegion.PageInGcRegion(addr))
                        {
                            MemoryCategory.AddPage("Heaps", "GC Heap", privatePage);
                        }
                        else
                        {
                            MemoryCategory.AddPage("Heaps", "Private VirtualAlloc", privatePage);
                        }
                        break;

                    case    "Stack":
                        string thread = null;
                        if (fields.Length >= 6 && fields[4] == "ThreadID")
                        {
                            thread = fields[4] + " " + fields[5];
                        }
                        MemoryCategory.AddPage("Stacks", thread, privatePage);
                        break;

                    case    "Process":
                        MemoryCategory.AddPage("Heaps", "Process Heap", privatePage);
                        break;

                    case    "UNKNOWN_MAPPED":
                        MemoryCategory.AddPage("Other Stuff", "Unknown Mapped", privatePage);
                        break;

                    case    "DATAFILE_MAPPED":
                        string fileName = "<Unknown>";
                        if (fields.Length == 6)
                        {
                            fileName = fields[5];
                        }
                        MemoryCategory.AddPage("Mapped data", fileName, privatePage);
                        break;

                    case    "Private":
                        MemoryCategory.AddPage("Heaps", "Private Heaps", privatePage);
                        break;

                    case    "TEB":
                        MemoryCategory.AddPage("Other Stuff", "TEB", privatePage);
                        break;

                    default:
                        MemoryCategory.AddPage("Modules", fields[2], privatePage);
                        break;
                    }
                }
                else if (fields.Length >= 2 &&
                         fields[0].IndexOf("0xc") == 0 &&
                         fields[1] == "->")
                {
                    MemoryCategory.AddPage("Other Stuff", "Page Tables", true);
                }
            }

            MemoryCategory.PrintCategories();
        }
Exemplo n.º 8
0
 internal static void AddPage(string categoryName, string subCategoryName, bool privatePage)
 {
     totalList    = AddPage(totalList, "Grand Total", null, privatePage);
     categoryList = AddPage(categoryList, categoryName, subCategoryName, privatePage);
 }