Example #1
0
 public ReferenceNode(HeapSnapshot map, int type, bool inverse)
 {
     this.map     = map;
     this.type    = type;
     TypeName     = map.GetTypeName(type);
     this.inverse = inverse;
 }
Example #2
0
 public ReferenceNode(HeapSnapshot map, int type, PathTree pathTree)
 {
     this.map      = map;
     this.type     = type;
     TypeName      = map.GetTypeName(type);
     this.pathTree = pathTree;
     FillRootPaths();
 }
 void AddShot(HeapSnapshot shot)
 {
     shots.Add(shot);
     if (HeapSnapshotAdded != null)
     {
         HeapSnapshotAdded(this, new HeapShotEventArgs(shot));
     }
 }
Example #4
0
        public static HeapSnapshot GetDiff(HeapSnapshot oldMap, HeapSnapshot newMap)
        {
            HeapSnapshot dif = new HeapSnapshot();

            dif.fieldNames      = newMap.fieldNames;
            dif.fieldReferences = newMap.fieldReferences;
            dif.inverseRefs     = newMap.inverseRefs;
            dif.objects         = newMap.objects;
            dif.objectCodes     = newMap.objectCodes;
            dif.references      = newMap.references;
            dif.totalMemory     = newMap.totalMemory;
            dif.typeIndices     = newMap.typeIndices;
            dif.types           = newMap.types;
            dif.RemoveData(oldMap);
            dif.name = string.Format("Diff from {0} to {1}", oldMap.Name, newMap.Name);
            return(dif);
        }
Example #5
0
 public void RemoveData(HeapSnapshot otherShot)
 {
     types           = (TypeInfo[])types.Clone();
     filteredObjects = new bool [objects.Length];
     for (int n = 0; n < otherShot.objects.Length; n++)
     {
         int i = Array.BinarySearch(objectCodes, otherShot.objects[n].Code);
         // FIXME: we don't keep track of objects that have moved,
         // so those are treated as different objects right now.
         if (i >= 0)
         {
             filteredObjects [i] = true;
             long t = objects[i].Type;
             types [t].ObjectCount--;
             //types [t].TotalSize -= objects[i].Size;
             filteredCount++;
             //this.totalMemory -= objects[i].Size;
         }
     }
 }
        private void ReadLogFileChunk_Object(HeapEvent he)
        {
            if (he.Type == HeapEvent.EventType.Start)
            {
                //Console.WriteLine ("ppe: START");
                return;
            }
            else if (he.Type == HeapEvent.EventType.End)
            {
                //Console.WriteLine ("ppe: END");
                HeapSnapshot shot = new HeapSnapshot();
                shotCount++;
                shot.Build(shotCount.ToString(), currentData);
                AddShot(shot);
            }
            if (he.Type == HeapEvent.EventType.Object)
            {
                ObjectInfo ob = new ObjectInfo();
                ob.Code      = currentObjBase + he.Object;
                ob.Size      = he.Size;
                ob.RefsIndex = currentData.ReferenceCodes.Count;
                ob.RefsCount = he.ObjectRefs != null ? he.ObjectRefs.Length : 0;
                currentData.ObjectTypeCodes.Add(currentPtrBase + he.Class);
                totalMemory += ob.Size;
                if (ob.Size != 0)
                {
                    currentData.RealObjectCount++;
                }

                // Read referenceCodes

                ulong lastOff = 0;
                for (int n = 0; n < ob.RefsCount; n++)
                {
                    currentData.ReferenceCodes.Add(he.ObjectRefs [n] + currentObjBase);
                    lastOff += he.RelOffset [n];
                    currentData.FieldReferenceCodes.Add(lastOff);
                }
                currentData.ObjectsList.Add(ob);
            }
            else if (he.Type == HeapEvent.EventType.Root)
            {
                for (int n = 0; n < he.RootRefs.Length; n++)
                {
                    ObjectInfo ob = new ObjectInfo();
                    ob.Size      = 0;
                    ob.RefsIndex = currentData.ReferenceCodes.Count;
                    ob.RefsCount = 1;
                    long type = UnknownTypeId;
                    switch (he.RootRefTypes [n] & HeapEvent.RootType.TypeMask)
                    {
                    case HeapEvent.RootType.Stack: type = StackObjectId; ob.Code = StackObjectId; break;

                    case HeapEvent.RootType.Finalizer: type = FinalizerObjectId; ob.Code = --rootId; break;

                    case HeapEvent.RootType.Handle: type = HandleObjectId; ob.Code = --rootId; break;

                    case HeapEvent.RootType.Other: type = OtherRootObjectId; ob.Code = --rootId; break;

                    case HeapEvent.RootType.Misc: type = MiscRootObjectId; ob.Code = --rootId; break;

                    default:
                        Console.WriteLine("pp1:"); break;
                    }
                    currentData.ObjectTypeCodes.Add(type);
                    currentData.ReferenceCodes.Add(he.RootRefs [n] + currentObjBase);
                    currentData.FieldReferenceCodes.Add(0);
                    currentData.ObjectsList.Add(ob);
                    currentData.RealObjectCount++;
                }
            }
        }
Example #7
0
 internal PathTree(HeapSnapshot map)
 {
     this.map = map;
 }
Example #8
0
 public HeapShotEventArgs(HeapSnapshot shot)
 {
     HeapSnapshot = shot;
 }