private void DrawValueFor(FieldDescription field, BytesAndOffset bytesAndOffset) { var typeDescription = _unpackedCrawl.typeDescriptions[field.typeIndex]; switch (typeDescription.name) { case "System.Int32": GUILayout.Label(_primitiveValueReader.ReadInt32(bytesAndOffset).ToString()); break; case "System.Int64": GUILayout.Label(_primitiveValueReader.ReadInt64(bytesAndOffset).ToString()); break; case "System.UInt32": GUILayout.Label(_primitiveValueReader.ReadUInt32(bytesAndOffset).ToString()); break; case "System.UInt64": GUILayout.Label(_primitiveValueReader.ReadUInt64(bytesAndOffset).ToString()); break; case "System.Int16": GUILayout.Label(_primitiveValueReader.ReadInt16(bytesAndOffset).ToString()); break; case "System.UInt16": GUILayout.Label(_primitiveValueReader.ReadUInt16(bytesAndOffset).ToString()); break; case "System.Byte": GUILayout.Label(_primitiveValueReader.ReadByte(bytesAndOffset).ToString()); break; case "System.SByte": GUILayout.Label(_primitiveValueReader.ReadSByte(bytesAndOffset).ToString()); break; case "System.Char": GUILayout.Label(_primitiveValueReader.ReadChar(bytesAndOffset).ToString()); break; case "System.Boolean": GUILayout.Label(_primitiveValueReader.ReadBool(bytesAndOffset).ToString()); break; case "System.Single": GUILayout.Label(_primitiveValueReader.ReadSingle(bytesAndOffset).ToString()); break; case "System.Double": GUILayout.Label(_primitiveValueReader.ReadDouble(bytesAndOffset).ToString()); break; case "System.IntPtr": GUILayout.Label(_primitiveValueReader.ReadPointer(bytesAndOffset).ToString("X")); break; default: if (!typeDescription.isValueType) { ThingInMemory item = GetThingAt(bytesAndOffset.ReadPointer()); if (item == null) { EditorGUI.BeginDisabledGroup(true); GUILayout.Button("Null"); EditorGUI.EndDisabledGroup(); } else { DrawLinks(new ThingInMemory[] { item }); } } else { DrawFields(typeDescription, bytesAndOffset); } break; } }
public void SelectThing(ThingInMemory thing) { _selectedThing = thing; _shortestPath = _shortestPathToRootFinder.FindFor(thing); }
public bool IsRoot(ThingInMemory thing, out string reason) { reason = null; if (thing is StaticFields) { reason = "Static fields are global variables. Anything they reference will not be unloaded."; return(true); } if (thing is ManagedObject) { return(false); } if (thing is GCHandle) { return(false); } var nativeObject = thing as NativeUnityEngineObject; if (nativeObject == null) { throw new ArgumentException("Unknown type: " + thing.GetType()); } if (nativeObject.isManager) { reason = "this is an internal unity'manager' style object, which is a global object that will never be unloaded"; return(true); } if (nativeObject.isDontDestroyOnLoad) { reason = "DontDestroyOnLoad() was called on this object, so it will never be unloaded"; return(true); } if ((nativeObject.hideFlags & HideFlags.DontUnloadUnusedAsset) != 0) { reason = "the DontUnloadUnusedAsset hideflag is set on this object. Unity's builtin resources set this flag. Users can also set the flag themselves"; return(true); } if (nativeObject.isPersistent) { return(false); } if (IsComponent(nativeObject.classID)) { reason = "this is a component, living on a gameobject, that is either part of the loaded scene, or was generated by script. It will be unloaded on next scene load."; return(true); } if (IsGameObject(nativeObject.classID)) { reason = "this is a gameobject, that is either part of the loaded scene, or was generated by script. It will be unloaded on next scene load if nobody is referencing it"; return(true); } if (IsAssetBundle(nativeObject.classID)) { reason = "this object is an assetbundle, which is never unloaded automatically, but only through an explicit .Unload() call."; return(true); } reason = "This object is a root, but the memory profiler UI does not yet understand why"; return(true); }
public void SelectThing(ThingInMemory thing) { _selectedItem = _items.First(i => i._thingInMemory == thing); _selectedGroup = _selectedItem._group; RefreshCachedRects(false); }
public void SelectThing(ThingInMemory thing) { _inspector.SelectThing(thing); _treeMapView.SelectThing(thing); }
public void FinishSnapshot() { allObjects = new ThingInMemory[0].Concat(gcHandles).Concat(nativeObjects).Concat(staticFields).Concat(managedObjects).ToArray(); totalSize = allObjects != null?allObjects.Sum(o => o.size) : 0; }
private int CompareData(int id1, int id2, int col) { ThingInMemory thing1 = m_unpackedCrawl.allObjects[id1]; NativeUnityEngineObject nativeObject1 = thing1 as NativeUnityEngineObject; ThingInMemory thing2 = m_unpackedCrawl.allObjects[id2]; NativeUnityEngineObject nativeObject2 = thing2 as NativeUnityEngineObject; switch ((Column)col) { case Column.Name: if (nativeObject1 != null && nativeObject2 != null) { return(nativeObject1.name.CompareTo(nativeObject2.name)); } else if (nativeObject1 != null) { return(-1); } else if (nativeObject2 != null) { return(1); } else { return(0); } case Column.Type: // this depends on the fact that HighLevelAPI.allGameObjects concatenates objects in the order we want return(id1 - id2); case Column.Size: return(-thing1.size.CompareTo(thing2.size)); case Column.ClassName: if (nativeObject1 != null && nativeObject2 != null) { return(nativeObject1.className.CompareTo(nativeObject2.className)); } else if (nativeObject1 != null) { return(-1); } else if (nativeObject2 != null) { return(1); } else { return(0); } case Column.InstanceID: if (nativeObject1 != null && nativeObject2 != null) { return(nativeObject1.instanceID.CompareTo(nativeObject2.instanceID)); } else if (nativeObject1 != null) { return(-1); } else if (nativeObject2 != null) { return(1); } else { return(0); } } return(0); }
private GUIContent DataForGrid(int id, int col) { string str = "undefined"; ThingInMemory thing = m_unpackedCrawl.allObjects[id]; NativeUnityEngineObject nativeObject = thing as NativeUnityEngineObject; switch ((Column)col) { case Column.Name: if (nativeObject != null) { str = nativeObject.name; } if (str.Equals("")) { str = "unnamed"; } if (thing.ignored) { str = "<filtered>"; } break; case Column.Type: str = ThingTypeToString(indexToThingType(id)); if (thing.ignored) { str = "<filtered>"; } break; case Column.Size: str = EditorUtility.FormatBytes(thing.size); if (thing.ignored) { str = "<filtered>"; } break; case Column.ClassName: if (nativeObject != null) { str = nativeObject.className; } if (thing.ignored) { str = "<filtered>"; } break; case Column.InstanceID: if (nativeObject != null) { str = nativeObject.instanceID.ToString(); } if (thing.ignored) { str = "<filtered>"; } break; } return(new GUIContent(str)); }
public void SelectThing(ThingInMemory thing) { _selectedThing = thing; }