Example #1
0
        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 = -2; ob.Code = StackObjectId; break;
                    case HeapEvent.RootType.Finalizer: type = -3; ob.Code = --rootId; break;
                    case HeapEvent.RootType.Handle: type = -4; ob.Code = --rootId; break;
                    case HeapEvent.RootType.Other: type = -5; ob.Code = --rootId; break;
                    case HeapEvent.RootType.Misc: type = -6; 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 #2
0
        public void ResetHeapData()
        {
            ObjectsList.Clear ();
            ObjectTypeCodes.Clear ();
            ReferenceCodes.Clear ();
            FieldReferenceCodes.Clear ();
            RealObjectCount = 1;

            // The 'unknown' object
            ObjectInfo ob = new ObjectInfo ();
            ob.Code = ObjectMapReader.UnknownObjectId;
            ob.Size = 0;
            ob.RefsIndex = 0;
            ob.RefsCount = 0;
            ObjectTypeCodes.Add (ObjectMapReader.UnknownTypeId);
            ObjectsList.Add (ob);
        }
        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++;
                }
            }
        }