private Color ColorFor(ThingInMemory rb) { if (rb == null) { return(Color.gray); } if (rb is NativeUnityEngineObject) { return(Color.red); } if (rb is ManagedObject) { return(Color.Lerp(Color.blue, Color.white, 0.5f)); } if (rb is GCHandle) { return(Color.magenta); } if (rb is StaticFields) { return(Color.yellow); } throw new ArgumentException("Unexpected type: " + rb.GetType()); }
public string GetGroupName(ThingInMemory thing) { if (thing is NativeUnityEngineObject) return (thing as NativeUnityEngineObject).className ?? "MissingName"; if (thing is ManagedObject) return (thing as ManagedObject).typeDescription.name; return thing.GetType().Name; }
internal string GetGroupName(ThingInMemory thing) { if (thing is NativeUnityEngineObject) { return((thing as NativeUnityEngineObject).className ?? "MissingName"); } if (thing is ManagedObject) { return((thing as ManagedObject).typeDescription.name); } return(thing.GetType().Name); }
public string GetGroupName(ThingInMemory thing) { if (thing is NativeUnityEngineObject) { if (_dirtyObjectsy != null && _dirtyObjectsy.ContainsKey((thing as NativeUnityEngineObject).instanceID)) { return(""); } return((thing as NativeUnityEngineObject).className ?? "MissingName"); } if (thing is ManagedObject) { return((thing as ManagedObject).typeDescription.name); } return(thing.GetType().Name); }
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); }