public List <ClrTypeStats> LoadTypeStat() { var list = new List <ClrTypeStats>(); SQLiteCommand cmd = new SQLiteCommand(); cmd.Connection = cxion; cmd.CommandText = "SELECT Id, Name, MethodTable, Count, TotalSize FROM Types"; SQLiteDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { int id = dr.GetInt32(0); var name = dr.GetString(1); ulong methodTable = (ulong)dr.GetInt64(2); var count = dr.GetInt64(3); var totalSize = (ulong)dr.GetInt64(4); ClrType type = ClrDump.GetType(methodTable); if (type == null) { type = ClrDump.GetType(name); } if (type == null) { type = new ClrTypeError(name); } var clrTypeStats = new ClrTypeStats(id, type, count, totalSize); list.Add(clrTypeStats); } return(list); }
public void InsertTypeStat(ClrTypeStats stats) { paramId_InsertType.Value = stats.Id; paramName_InsertType.Value = stats.Type.Name; paramMethodTable_InsertType.Value = stats.MethodTable; paramTotalSize_InsertType.Value = stats.TotalSize; paramCount_InsertType.Value = stats.NbInstances; cmdInsertType.ExecuteNonQuery(); }
private void StoreData(CancellationToken token) { BeginUpdate(); Dictionary <ClrType, ClrTypeStats> stats = new Dictionary <ClrType, ClrTypeStats>(); foreach (var address in ClrDump.Heap.EnumerateObjectAddresses()) { ClrType type = ClrDump.Heap.GetObjectType(address); if (type == null) { continue; } ulong size = type.GetSize(address); ClrTypeStats stat; if (!stats.TryGetValue(type, out stat)) { stat = new ClrTypeStats(stats.Count, type); stats[type] = stat; } stat.Inc(size); InsertInstances(stat.Id, address); type.EnumerateRefsOfObject(address, delegate(ulong child, int offset) { InsertReferences(child, address); }); n++; if (n % 1024 * 64 == 0) { if (token.IsCancellationRequested) { return; } ClrDump.MessageBus.Status(GetStats()); } } ClrDump.MessageBus.Log(this, "Inserting type stats..."); foreach (var stat in stats.Values) { InsertTypeStat(stat); } EndUpdate(); ClrDump.MessageBus.Status("Cache Initialized.", StatusType.EndTask); }
private void StoreData(CancellationToken token) { BeginUpdate(); Dictionary<ClrType, ClrTypeStats> stats = new Dictionary<ClrType, ClrTypeStats>(); foreach (var address in ClrDump.Heap.EnumerateObjectAddresses()) { ClrType type = ClrDump.Heap.GetObjectType(address); if (type == null) { continue; } ulong size = type.GetSize(address); ClrTypeStats stat; if (!stats.TryGetValue(type, out stat)) { stat = new ClrTypeStats(stats.Count, type); stats[type] = stat; } stat.Inc(size); InsertInstances(stat.Id, address); type.EnumerateRefsOfObject(address, delegate (ulong child, int offset) { InsertReferences(child, address); }); n++; if( n % 1024*64==0) { if( token.IsCancellationRequested) { return; } ClrDump.MessageBus.Status(GetStats()); } } ClrDump.MessageBus.Log(this, "Inserting type stats..."); foreach (var stat in stats.Values) { InsertTypeStat(stat); } EndUpdate(); ClrDump.MessageBus.Status("Cache Initialized.", StatusType.EndTask); }
public List<ClrTypeStats> LoadTypeStat() { var list = new List<ClrTypeStats>(); SQLiteCommand cmd = new SQLiteCommand(); cmd.Connection = cxion; cmd.CommandText = "SELECT Id, Name, MethodTable, Count, TotalSize FROM Types"; SQLiteDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { int id = dr.GetInt32(0); var name = dr.GetString(1); ulong methodTable = (ulong)dr.GetInt64(2); var count = dr.GetInt64(3); var totalSize = (ulong)dr.GetInt64(4); var type = ClrDump.GetType(methodTable); var clrTypeStats = new ClrTypeStats(id, type, count, totalSize); list.Add(clrTypeStats); } return list; }