public static void RegisterItem([NotNull] CrawlItem item) { if (!SnapshotHistory.IsNew(item.Object)) { return; } var stats = DemandTypeStats(item.Object.GetType()); stats.Count++; stats.SelfSize += item.SelfSize; stats.TotalSize += item.TotalSize; var unityObject = item.Object as UnityEngine.Object; if (unityObject != null) { stats.NativeSize += Profiler.GetRuntimeMemorySizeLong(unityObject); } if (stats.tracked) { stats.DemandInstanceStats(item.Object).Size = item.TotalSize; } }
private void CleanupUnchanged() { if (Children != null) { foreach (var c in Children) { c.CleanupUnchanged(); } Children.RemoveAll(c => !c.SubtreeUpdated); SubtreeUpdated = Children.Count > 0; } SubtreeUpdated |= SnapshotHistory.IsNew(Object); }
public static void RegisterInstance([NotNull] CrawlItem parent, [NotNull] string name, [NotNull] object instance) { if (!SnapshotHistory.IsNew(instance)) { return; } var stats = DemandTypeStats(instance.GetType()); if (!stats.tracked) { return; } var instanceStats = stats.DemandInstanceStats(instance); var rootPath = parent.GetRootPath() + "." + name; instanceStats.RootPaths.Add(rootPath); }
private long CalculateSelfManagedSize() { if (!SnapshotHistory.IsNew(Object)) { return(0); } string str = Object as string; if (str != null) { // string needs special handling int strSize = 3 * IntPtr.Size + 2; strSize += str.Length * sizeof(char); int pad = strSize % IntPtr.Size; if (pad != 0) { strSize += IntPtr.Size - pad; } return(strSize); } if (Object.GetType().IsArray) { var elementType = Object.GetType().GetElementType(); if (elementType != null && (elementType.IsValueType || elementType.IsPrimitive || elementType.IsEnum)) { // no overhead for array return(0); } else { int arraySize = GetTotalArrayLength((Array)Object); return(IntPtr.Size * arraySize); } } return(TypeData.Get(Object.GetType()).Size); }
public void CleanupInternal(CrawlSettings crawlSettings) { if (!crawlSettings.PrintChildren) { Children = null; } if (crawlSettings.MaxDepth > 0 && depth >= crawlSettings.MaxDepth) { Children = null; } if (SnapshotHistory.IsPresent() && SnapshotHistory.IsNew(Object)) { Name = Name + " (new)"; } // check for destroyed objects var unityObject = Object as Object; if (!ReferenceEquals(unityObject, null) && !unityObject) { const string destroyedObjectString = "(destroyed Unity Object)"; if (string.IsNullOrWhiteSpace(Name)) { Name = destroyedObjectString; } else { Name = Name + " " + destroyedObjectString; } Children = null; } if (Children == null) { return; } if (crawlSettings.PrintOnlyGameObjects) { Children.RemoveAll(c => !(c.Object is GameObject)); } int fullChildrenCount = Children.Count; if (crawlSettings.MinItemSize > 0) { Children.RemoveAll(c => c.TotalSize < crawlSettings.MinItemSize); } if (crawlSettings.MaxChildren > 0 && Children.Count > crawlSettings.MaxChildren) { Children.RemoveRange(crawlSettings.MaxChildren, Children.Count - crawlSettings.MaxChildren); } if (Children.Count < fullChildrenCount) { childrenFiltered = true; } depth++; foreach (var child in Children) { child.CleanupInternal(crawlSettings); } depth--; }