private static void Dump()
    {
        Debug.Log("Writing snapshot...");
        MemorySnapshot memorySnapshot = new MemorySnapshot();

        ClearFileName();
        MemorySnapshot.TypeData[] array = new MemorySnapshot.TypeData[memorySnapshot.types.Count];
        memorySnapshot.types.Values.CopyTo(array, 0);
        Array.Sort(array, 0, array.Length, new InstanceCountComparer());
        using (StreamWriter streamWriter = new StreamWriter(GetFileName("memory_instances")))
        {
            streamWriter.WriteLine("Delta,Instances,NumArrayEntries,Type Name");
            MemorySnapshot.TypeData[] array2 = array;
            foreach (MemorySnapshot.TypeData typeData in array2)
            {
                if (typeData.instanceCount != 0)
                {
                    int num = typeData.instanceCount;
                    if (previousSnapshot != null)
                    {
                        MemorySnapshot.TypeData typeData2 = MemorySnapshot.GetTypeData(typeData.type, previousSnapshot.types);
                        num = typeData.instanceCount - typeData2.instanceCount;
                    }
                    streamWriter.WriteLine(num + "," + typeData.instanceCount + "," + typeData.numArrayEntries + ",\"" + typeData.type.ToString() + "\"");
                }
            }
        }
        using (StreamWriter streamWriter2 = new StreamWriter(GetFileName("memory_hierarchies")))
        {
            streamWriter2.WriteLine("Delta,Count,Type Hierarchy");
            MemorySnapshot.TypeData[] array3 = array;
            foreach (MemorySnapshot.TypeData typeData3 in array3)
            {
                if (typeData3.instanceCount != 0)
                {
                    foreach (KeyValuePair <MemorySnapshot.HierarchyNode, int> hierarchy in typeData3.hierarchies)
                    {
                        int num2 = hierarchy.Value;
                        if (previousSnapshot != null)
                        {
                            MemorySnapshot.TypeData typeData4 = MemorySnapshot.GetTypeData(typeData3.type, previousSnapshot.types);
                            int value = 0;
                            if (typeData4.hierarchies.TryGetValue(hierarchy.Key, out value))
                            {
                                num2 = hierarchy.Value - value;
                            }
                        }
                        streamWriter2.WriteLine(num2 + "," + hierarchy.Value + ", \"" + typeData3.type.ToString() + ": " + hierarchy.Key.ToString() + "\"");
                    }
                }
            }
        }
        previousSnapshot = memorySnapshot;
        Debug.Log("Done writing snapshot!");
    }
    public static void DebugDumpGarbageStats()
    {
        Debug.Log("Writing reference stats...");
        MemorySnapshot memorySnapshot = new MemorySnapshot();

        ClearFileName();
        MemorySnapshot.TypeData[] array = new MemorySnapshot.TypeData[memorySnapshot.types.Count];
        memorySnapshot.types.Values.CopyTo(array, 0);
        Array.Sort(array, 0, array.Length, new InstanceCountComparer());
        using (StreamWriter streamWriter = new StreamWriter(GetFileName("garbage_instances")))
        {
            MemorySnapshot.TypeData[] array2 = array;
            foreach (MemorySnapshot.TypeData typeData in array2)
            {
                if (typeData.instanceCount != 0)
                {
                    int num = typeData.instanceCount;
                    if (previousSnapshot != null)
                    {
                        MemorySnapshot.TypeData typeData2 = MemorySnapshot.GetTypeData(typeData.type, previousSnapshot.types);
                        num = typeData.instanceCount - typeData2.instanceCount;
                    }
                    streamWriter.WriteLine(num + ", " + typeData.instanceCount + ", \"" + typeData.type.ToString() + "\"");
                }
            }
        }
        Array.Sort(array, 0, array.Length, new RefCountComparer());
        using (StreamWriter streamWriter2 = new StreamWriter(GetFileName("garbage_refs")))
        {
            MemorySnapshot.TypeData[] array3 = array;
            foreach (MemorySnapshot.TypeData typeData3 in array3)
            {
                if (typeData3.refCount != 0)
                {
                    int num2 = typeData3.refCount;
                    if (previousSnapshot != null)
                    {
                        MemorySnapshot.TypeData typeData4 = MemorySnapshot.GetTypeData(typeData3.type, previousSnapshot.types);
                        num2 = typeData3.refCount - typeData4.refCount;
                    }
                    streamWriter2.WriteLine(num2 + ", " + typeData3.refCount + ", \"" + typeData3.type.ToString() + "\"");
                }
            }
        }
        MemorySnapshot.FieldCount[] array4 = new MemorySnapshot.FieldCount[memorySnapshot.fieldCounts.Count];
        memorySnapshot.fieldCounts.Values.CopyTo(array4, 0);
        Array.Sort(array4, 0, array4.Length, new FieldCountComparer());
        using (StreamWriter streamWriter3 = new StreamWriter(GetFileName("garbage_fields")))
        {
            MemorySnapshot.FieldCount[] array5 = array4;
            foreach (MemorySnapshot.FieldCount fieldCount in array5)
            {
                int num3 = fieldCount.count;
                if (previousSnapshot != null)
                {
                    foreach (KeyValuePair <int, MemorySnapshot.FieldCount> fieldCount2 in previousSnapshot.fieldCounts)
                    {
                        if (fieldCount2.Value.name == fieldCount.name)
                        {
                            num3 = fieldCount.count - fieldCount2.Value.count;
                            break;
                        }
                    }
                }
                streamWriter3.WriteLine(num3 + ", " + fieldCount.count + ", \"" + fieldCount.name + "\"");
            }
        }
        memorySnapshot.WriteTypeDetails(previousSnapshot);
        previousSnapshot = memorySnapshot;
        Debug.Log("Done writing reference stats!");
    }