private void RecordAllocation(ulong timestamp, AllocationSampleInfo allocation) { if (!_tempDataTypeAllocations.TryGetValue(allocation.ClassIntId, out Dictionary <ulong, DataTypeMemoryUsage> dict)) { dict = new Dictionary <ulong, DataTypeMemoryUsage>(); _tempDataTypeAllocations.Add(allocation.ClassIntId, dict); } if (!dict.TryGetValue(timestamp, out DataTypeMemoryUsage sample)) { sample = new DataTypeMemoryUsage { TimeMilliseconds = timestamp }; dict.Add(timestamp, sample); } sample.ObjectsCount += allocation.AllocationCount; sample.MemorySize += allocation.MemorySize; }
private void RecordSnapshot(ulong timestamp, AllocationSampleInfo allocation) { if (!DataTypeSnapshots.TryGetValue(allocation.ClassIntId, out List <DataTypeMemoryUsage> list)) { DataTypeSnapshots.Add( allocation.ClassIntId, new List <DataTypeMemoryUsage>() { new DataTypeMemoryUsage { TimeMilliseconds = timestamp, ObjectsCount = allocation.AllocationCount, MemorySize = allocation.MemorySize } }); return; } var mu = list[list.Count - 1]; if (mu.TimeMilliseconds == timestamp) { mu.ObjectsCount += allocation.AllocationCount; mu.MemorySize += allocation.MemorySize; } else { list.Add(new DataTypeMemoryUsage { TimeMilliseconds = timestamp, ObjectsCount = mu.ObjectsCount + allocation.AllocationCount, MemorySize = mu.MemorySize + allocation.MemorySize }); } }