Example #1
0
        void AddReference(int parentObject, int obj, int refsToRoot, uint 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;
                    if (fieldReferences == null)
                    {
                        fieldReferences = new ArrayList();
                    }
                    fieldReferences.Add(f);
                }
            }

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

            RefCount++;

            RootRefInfo rr = new RootRefInfo();

            rr.References = refsToRoot;
            rr.Memory     = rootMem;
            refObjects.Add(obj, rr);
            TotalMemory += map.GetObjectSize(obj);
        }
Example #2
0
		void AddReference (int parentObject, int obj, int refsToRoot, uint 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;
					if (fieldReferences == null)
						fieldReferences = new ArrayList ();
					fieldReferences.Add (f);
				}
			}
			
			if (refObjects.ContainsKey (obj)) {
				RootRefInfo ri = refObjects [obj];
				ri.References += refsToRoot;
				ri.Memory += rootMem;
				refObjects [obj] = ri;
				return;
			}

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