コード例 #1
0
 public static MemoryElement GetTreeRoot(ObjectMemoryInfo[] memoryObjectList, int[] referencesIndices)
 {
   ObjectInfo[] objectInfoArray = new ObjectInfo[memoryObjectList.Length];
   for (int index = 0; index < memoryObjectList.Length; ++index)
     objectInfoArray[index] = new ObjectInfo()
     {
       instanceId = memoryObjectList[index].instanceId,
       memorySize = memoryObjectList[index].memorySize,
       reason = memoryObjectList[index].reason,
       name = memoryObjectList[index].name,
       className = memoryObjectList[index].className
     };
   int num = 0;
   for (int index1 = 0; index1 < memoryObjectList.Length; ++index1)
   {
     for (int index2 = 0; index2 < memoryObjectList[index1].count; ++index2)
     {
       int referencesIndex = referencesIndices[index2 + num];
       if (objectInfoArray[referencesIndex].referencedBy == null)
         objectInfoArray[referencesIndex].referencedBy = new List<ObjectInfo>();
       objectInfoArray[referencesIndex].referencedBy.Add(objectInfoArray[index1]);
     }
     num += memoryObjectList[index1].count;
   }
   MemoryElement memoryElement = new MemoryElement();
   Array.Sort<ObjectInfo>(objectInfoArray, new Comparison<ObjectInfo>(MemoryElementDataManager.SortByMemoryClassName));
   memoryElement.AddChild(new MemoryElement("Scene Memory", MemoryElementDataManager.GenerateObjectTypeGroups(objectInfoArray, MemoryElementDataManager.ObjectTypeFilter.Scene)));
   memoryElement.AddChild(new MemoryElement("Assets", MemoryElementDataManager.GenerateObjectTypeGroups(objectInfoArray, MemoryElementDataManager.ObjectTypeFilter.Asset)));
   memoryElement.AddChild(new MemoryElement("Builtin Resources", MemoryElementDataManager.GenerateObjectTypeGroups(objectInfoArray, MemoryElementDataManager.ObjectTypeFilter.BuiltinResource)));
   memoryElement.AddChild(new MemoryElement("Not Saved", MemoryElementDataManager.GenerateObjectTypeGroups(objectInfoArray, MemoryElementDataManager.ObjectTypeFilter.DontSave)));
   memoryElement.AddChild(new MemoryElement("Other", MemoryElementDataManager.GenerateObjectTypeGroups(objectInfoArray, MemoryElementDataManager.ObjectTypeFilter.Other)));
   memoryElement.children.Sort(new Comparison<MemoryElement>(MemoryElementDataManager.SortByMemorySize));
   return memoryElement;
 }
コード例 #2
0
		private static List<MemoryElement> GenerateObjectTypeGroups(ObjectInfo[] memory, MemoryElementDataManager.ObjectTypeFilter filter)
		{
			List<MemoryElement> list = new List<MemoryElement>();
			MemoryElement memoryElement = null;
			for (int i = 0; i < memory.Length; i++)
			{
				ObjectInfo objectInfo = memory[i];
				if (MemoryElementDataManager.GetObjectTypeFilter(objectInfo) == filter)
				{
					if (memoryElement == null || objectInfo.className != memoryElement.name)
					{
						memoryElement = new MemoryElement(objectInfo.className);
						list.Add(memoryElement);
					}
					memoryElement.AddChild(new MemoryElement(objectInfo, true));
				}
			}
			list.Sort(new Comparison<MemoryElement>(MemoryElementDataManager.SortByMemorySize));
			foreach (MemoryElement current in list)
			{
				current.children.Sort(new Comparison<MemoryElement>(MemoryElementDataManager.SortByMemorySize));
				if (filter == MemoryElementDataManager.ObjectTypeFilter.Other && !MemoryElementDataManager.HasValidNames(current.children))
				{
					current.children.Clear();
				}
			}
			return list;
		}
コード例 #3
0
 private static List<MemoryElement> GenerateObjectTypeGroups(ObjectInfo[] memory, MemoryElementDataManager.ObjectTypeFilter filter)
 {
   List<MemoryElement> memoryElementList = new List<MemoryElement>();
   MemoryElement memoryElement = (MemoryElement) null;
   foreach (ObjectInfo objectInfo in memory)
   {
     if (MemoryElementDataManager.GetObjectTypeFilter(objectInfo) == filter)
     {
       if (memoryElement == null || objectInfo.className != memoryElement.name)
       {
         memoryElement = new MemoryElement(objectInfo.className);
         memoryElementList.Add(memoryElement);
       }
       memoryElement.AddChild(new MemoryElement(objectInfo, true));
     }
   }
   memoryElementList.Sort(new Comparison<MemoryElement>(MemoryElementDataManager.SortByMemorySize));
   using (List<MemoryElement>.Enumerator enumerator = memoryElementList.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       MemoryElement current = enumerator.Current;
       current.children.Sort(new Comparison<MemoryElement>(MemoryElementDataManager.SortByMemorySize));
       if (filter == MemoryElementDataManager.ObjectTypeFilter.Other && !MemoryElementDataManager.HasValidNames(current.children))
         current.children.Clear();
     }
   }
   return memoryElementList;
 }
コード例 #4
0
 public MemoryElement(ObjectInfo memInfo, bool finalize)
 {
   this.expanded = false;
   this.memoryInfo = memInfo;
   this.name = this.memoryInfo.name;
   this.totalMemory = memInfo == null ? 0 : memInfo.memorySize;
   this.totalChildCount = 1;
   if (!finalize)
     return;
   this.children = new List<MemoryElement>();
 }
コード例 #5
0
		private static MemoryElementDataManager.ObjectTypeFilter GetObjectTypeFilter(ObjectInfo info)
		{
			switch (info.reason)
			{
			case 1:
				return MemoryElementDataManager.ObjectTypeFilter.BuiltinResource;
			case 2:
				return MemoryElementDataManager.ObjectTypeFilter.DontSave;
			case 3:
			case 8:
			case 9:
				return MemoryElementDataManager.ObjectTypeFilter.Asset;
			case 10:
				return MemoryElementDataManager.ObjectTypeFilter.Other;
			}
			return MemoryElementDataManager.ObjectTypeFilter.Scene;
		}
コード例 #6
0
 private static List<MemoryElement> GenerateObjectTypeGroups(ObjectInfo[] memory, ObjectTypeFilter filter)
 {
     List<MemoryElement> list = new List<MemoryElement>();
     MemoryElement item = null;
     foreach (ObjectInfo info in memory)
     {
         if (GetObjectTypeFilter(info) == filter)
         {
             if ((item == null) || (info.className != item.name))
             {
                 item = new MemoryElement(info.className);
                 list.Add(item);
             }
             item.AddChild(new MemoryElement(info, true));
         }
     }
     if (<>f__mg$cache0 == null)
     {
コード例 #7
0
		public static MemoryElement GetTreeRoot(ObjectMemoryInfo[] memoryObjectList, int[] referencesIndices)
		{
			ObjectInfo[] array = new ObjectInfo[memoryObjectList.Length];
			for (int i = 0; i < memoryObjectList.Length; i++)
			{
				array[i] = new ObjectInfo
				{
					instanceId = memoryObjectList[i].instanceId,
					memorySize = memoryObjectList[i].memorySize,
					reason = memoryObjectList[i].reason,
					name = memoryObjectList[i].name,
					className = memoryObjectList[i].className
				};
			}
			int num = 0;
			for (int j = 0; j < memoryObjectList.Length; j++)
			{
				for (int k = 0; k < memoryObjectList[j].count; k++)
				{
					int num2 = referencesIndices[k + num];
					if (array[num2].referencedBy == null)
					{
						array[num2].referencedBy = new List<ObjectInfo>();
					}
					array[num2].referencedBy.Add(array[j]);
				}
				num += memoryObjectList[j].count;
			}
			MemoryElement memoryElement = new MemoryElement();
			Array.Sort<ObjectInfo>(array, new Comparison<ObjectInfo>(MemoryElementDataManager.SortByMemoryClassName));
			memoryElement.AddChild(new MemoryElement("Scene Memory", MemoryElementDataManager.GenerateObjectTypeGroups(array, MemoryElementDataManager.ObjectTypeFilter.Scene)));
			memoryElement.AddChild(new MemoryElement("Assets", MemoryElementDataManager.GenerateObjectTypeGroups(array, MemoryElementDataManager.ObjectTypeFilter.Asset)));
			memoryElement.AddChild(new MemoryElement("Builtin Resources", MemoryElementDataManager.GenerateObjectTypeGroups(array, MemoryElementDataManager.ObjectTypeFilter.BuiltinResource)));
			memoryElement.AddChild(new MemoryElement("Not Saved", MemoryElementDataManager.GenerateObjectTypeGroups(array, MemoryElementDataManager.ObjectTypeFilter.DontSave)));
			memoryElement.AddChild(new MemoryElement("Other", MemoryElementDataManager.GenerateObjectTypeGroups(array, MemoryElementDataManager.ObjectTypeFilter.Other)));
			memoryElement.children.Sort(new Comparison<MemoryElement>(MemoryElementDataManager.SortByMemorySize));
			return memoryElement;
		}
コード例 #8
0
 private static int SortByMemoryClassName(ObjectInfo x, ObjectInfo y)
 {
   return y.className.CompareTo(x.className);
 }
コード例 #9
0
ファイル: HeapshotReader.cs プロジェクト: randomize/VimConfig
 private void ReadObject(BinaryReader reader)
 {
     uint num3;
     uint num = reader.ReadUInt32();
     uint key = reader.ReadUInt32();
     ObjectInfo item = new ObjectInfo {
         code = num,
         size = reader.ReadUInt32()
     };
     if (!this.types.ContainsKey(key))
     {
         throw new Exception(string.Format("Failed to find type info {0} for object {1}!!!", key, num));
     }
     item.typeInfo = this.types[key];
     while ((num3 = reader.ReadUInt32()) != 0)
     {
         ReferenceInfo info2 = new ReferenceInfo {
             code = num3
         };
         uint num4 = reader.ReadUInt32();
         if (num4 == 0)
         {
             info2.fieldInfo = null;
         }
         else if (item.typeInfo.fields.ContainsKey(num4))
         {
             info2.fieldInfo = item.typeInfo.fields[num4];
         }
         else
         {
             info2.fieldInfo = null;
         }
         item.references.Add(info2);
     }
     if (this.objects.ContainsKey(num))
     {
         throw new Exception(string.Format("Object {0} was already loaded?!", num));
     }
     item.type = (num != key) ? ObjectType.Managed : ObjectType.Root;
     this.objects[num] = item;
     this.allObjects.Add(item);
 }
コード例 #10
0
 private static int SortByMemoryClassName(ObjectInfo x, ObjectInfo y)
 {
     return(y.className.CompareTo(x.className));
 }