Пример #1
0
        RootRefInfo AddReference(int parentObject, int obj, int tnode, int refsToRoot, ulong rootMem, string fieldName)
        {
            if (parentObject != -1 && !parentObjects.ContainsKey(parentObject))
            {
                parentObjects [parentObject] = parentObject;
                RefsToParent++;
                RefsToRoot += refsToRoot;
                RootMemory += rootMem;
            }

            if (fieldName != null)
            {
                // Update field reference count
                bool ffound = false;
                if (fieldReferences != null)
                {
                    foreach (FieldReference f in fieldReferences)
                    {
                        if (f.FiledName == fieldName)
                        {
                            f.RefCount++;
                            ffound = true;
                            break;
                        }
                    }
                }
                if (!ffound)
                {
                    FieldReference f = new FieldReference();
                    f.FiledName = fieldName;
                    f.RefCount  = 1;
                    f.IsStatic  = map.IsStaticObject(obj);
                    if (fieldReferences == null)
                    {
                        fieldReferences = new List <HeapShot.Reader.FieldReference> ();
                    }
                    fieldReferences.Add(f);
                }
            }

            if (refObjects.ContainsKey(obj))
            {
                RootRefInfo ri = refObjects [obj];
                ri.References   += refsToRoot;
                ri.Memory       += rootMem;
                refObjects [obj] = ri;
                return(ri);
            }

            RefCount++;

            RootRefInfo rr = new RootRefInfo();

            rr.TreeNode   = tnode;
            rr.References = refsToRoot;
            rr.Memory     = rootMem;
            refObjects.Add(obj, rr);
            TotalMemory += map.GetObjectSize(obj);
            return(rr);
        }
Пример #2
0
        RootRefInfo AddReference(int parentObject, int obj, int tnode, int refsToRoot, ulong rootMem, string fieldName)
        {
            if (parentObject != -1 && !parentObjects.ContainsKey (parentObject)) {
                parentObjects [parentObject] = parentObject;
                RefsToParent++;
                RefsToRoot += refsToRoot;
                RootMemory += rootMem;
            }

            if (fieldName != null) {
                // Update field reference count
                bool ffound = false;
                if (fieldReferences != null) {
                    foreach (FieldReference f in fieldReferences) {
                        if (f.FiledName == fieldName) {
                            f.RefCount++;
                            ffound = true;
                            break;
                        }
                    }
                }
                if (!ffound) {
                    FieldReference f = new FieldReference ();
                    f.FiledName = fieldName;
                    f.RefCount = 1;
                    f.IsStatic = map.IsStaticObject (obj);
                    if (fieldReferences == null)
                        fieldReferences = new List<HeapShot.Reader.FieldReference> ();
                    fieldReferences.Add (f);
                }
            }

            if (refObjects.ContainsKey (obj)) {
                RootRefInfo ri = refObjects [obj];
                ri.References += refsToRoot;
                ri.Memory += rootMem;
                refObjects [obj] = ri;
                return ri;
            }

            RefCount++;

            RootRefInfo rr = new RootRefInfo ();
            rr.TreeNode = tnode;
            rr.References = refsToRoot;
            rr.Memory = rootMem;
            refObjects.Add (obj, rr);
            TotalMemory += map.GetObjectSize (obj);
            return rr;
        }