public void GetAllocations(List <FragAllocData> data, ulong addr_lo, ulong addr_hi) { // Find lower bound. var sa = m_Trace.AllocationsByAddress; if (sa.Count == 0) { return; } var key_lo = HeapAllocationInfo.CreateSearchKey(addr_lo); var key_hi = HeapAllocationInfo.CreateSearchKey(addr_hi); int index_lo = sa.BinarySearch(key_lo, new HeapAllocationInfo.EndComparer()); int index_hi = sa.BinarySearch(key_hi, new HeapAllocationInfo.StartComparer()); if (index_lo < 0) { index_lo = (~index_lo); } if (index_hi < 0) { index_hi = (~index_hi); } index_lo = Math.Min(Math.Max(0, index_lo), sa.Count - 1); index_hi = Math.Min(Math.Max(0, index_hi), sa.Count); for (int i = index_lo; i < index_hi; ++i) { ulong col = 0xefefefef; var a = sa[i]; foreach (var frame in a.BackTrace.Frames) { col = ((col << 60) | (col >> 4)) ^ frame.Address; } int r = Math.Min((int)(col & 0xff), 0xc0); int g = Math.Min((int)(col & 0xff00) >> 8, 0xc0); int b = Math.Min((int)(col & 0xff0000) >> 16, 0xc0); data.Add(new FragAllocData { Alloc = a, Color = Color.FromArgb(255, (int)col & 0xff, (int)(col >> 8) & 0xff, (int)(col >> 16) & 0xff) }); } }
protected void UpdateTree(HeapAllocationInfo info) { MemTreeNode leaf = Root; var heap = info.Heap; var stack = info.BackTrace; var scope = (EventScope) info.ScopeType; var scope_data = info.ScopeData; foreach (var axis in Perspective.Axes) { switch (axis) { case TreeAxis.Heap: leaf = leaf.GetChild(heap != null ? heap.Name : "(unknown heap)"); leaf.Icon = "heap"; break; case TreeAxis.CallStackReverse: BuildBackTraceNodes(stack, ref leaf, true); break; case TreeAxis.CallStack: BuildBackTraceNodes(stack, ref leaf, false); break; case TreeAxis.FileName: for (int i = stack.Frames.Count - 1; i >= 0; --i) { var frame = stack.Frames[i]; if (SuppressedSymbols.Contains(frame.Symbol)) continue; leaf = leaf.GetChild(Path.GetFileName(frame.FileName)); leaf.Icon = "file"; leaf.FileName = frame.FileName; leaf.LineNumber = frame.LineNumber; } break; case TreeAxis.AssetPath: if (scope == EventScope.Asset) { string[] elems = scope_data.Split('\\', '/'); for (int i = 0; i < elems.Length - 1; ++i) { leaf = leaf.GetChild(elems[i]); leaf.Icon = "folder"; } leaf = leaf.GetChild(elems[elems.Length - 1]); leaf.Icon = "asset"; } else { leaf = leaf.GetChild("(no asset)"); } break; case TreeAxis.AssetType: if (scope == EventScope.Asset) { leaf = leaf.GetChild(Path.GetExtension(scope_data)); leaf.Icon = "asset"; } else { leaf = leaf.GetChild("(no asset)"); } break; case TreeAxis.ComponentType: if (scope == EventScope.Component) { leaf = leaf.GetChild(scope_data); leaf.Icon = "component"; } else { leaf = leaf.GetChild("(no component)"); } break; } } do { leaf.SizeBytes += (long) info.SizeBytes; leaf.Count += 1; leaf = leaf.Parent; } while (leaf != null); }
protected void UpdateTree(HeapAllocationInfo info) { MemTreeNode leaf = Root; var heap = info.Heap; var stack = info.BackTrace; var scope = (EventScope)info.ScopeType; var scope_data = info.ScopeData; foreach (var axis in Perspective.Axes) { switch (axis) { case TreeAxis.Heap: leaf = leaf.GetChild(heap != null ? heap.Name : "(unknown heap)"); leaf.Icon = "heap"; break; case TreeAxis.CallStackReverse: BuildBackTraceNodes(stack, ref leaf, true); break; case TreeAxis.CallStack: BuildBackTraceNodes(stack, ref leaf, false); break; case TreeAxis.FileName: for (int i = stack.Frames.Count - 1; i >= 0; --i) { var frame = stack.Frames[i]; if (SuppressedSymbols.Contains(frame.Symbol)) { continue; } leaf = leaf.GetChild(Path.GetFileName(frame.FileName)); leaf.Icon = "file"; leaf.FileName = frame.FileName; leaf.LineNumber = frame.LineNumber; } break; case TreeAxis.AssetPath: if (scope == EventScope.Asset) { string[] elems = scope_data.Split('\\', '/'); for (int i = 0; i < elems.Length - 1; ++i) { leaf = leaf.GetChild(elems[i]); leaf.Icon = "folder"; } leaf = leaf.GetChild(elems[elems.Length - 1]); leaf.Icon = "asset"; } else { leaf = leaf.GetChild("(no asset)"); } break; case TreeAxis.AssetType: if (scope == EventScope.Asset) { leaf = leaf.GetChild(Path.GetExtension(scope_data)); leaf.Icon = "asset"; } else { leaf = leaf.GetChild("(no asset)"); } break; case TreeAxis.ComponentType: if (scope == EventScope.Component) { leaf = leaf.GetChild(scope_data); leaf.Icon = "component"; } else { leaf = leaf.GetChild("(no component)"); } break; } } do { leaf.SizeBytes += (long)info.SizeBytes; leaf.Count += 1; leaf = leaf.Parent; } while (leaf != null); }