Skip to content

Commit 1e4908f

Browse files
committed
Include object addresses in log
1 parent 495e42c commit 1e4908f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

UMS.Analysis/Structures/Objects/ManagedClassInstance.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace UMS.Analysis.Structures.Objects;
66
public readonly struct ManagedClassInstance
77
{
88
private readonly object? _parent;
9-
private readonly ulong _objectAddress;
10-
9+
10+
public readonly ulong ObjectAddress;
1111
public readonly BasicTypeInfoCache TypeInfo;
1212
public readonly IFieldValue[] Fields;
1313
public readonly TypeFlags TypeDescriptionFlags;
@@ -22,7 +22,7 @@ public ManagedClassInstance(SnapshotFile file, int typeDescriptionIndex, TypeFla
2222
throw new("This constructor can only be used for value types");
2323

2424
_parent = parent;
25-
_objectAddress = 0;
25+
ObjectAddress = 0;
2626
TypeInfo = file.GetTypeInfo(typeDescriptionIndex);
2727
TypeDescriptionFlags = flags;
2828
IsInitialized = true;
@@ -50,7 +50,7 @@ public ManagedClassInstance(SnapshotFile file, int typeDescriptionIndex, TypeFla
5050
public ManagedClassInstance(SnapshotFile file, RawManagedObjectInfo info, ManagedClassInstance? parent = null, int depth = 0)
5151
{
5252
_parent = parent;
53-
_objectAddress = info.SelfAddress;
53+
ObjectAddress = info.SelfAddress;
5454
TypeInfo = file.GetTypeInfo(info.TypeDescriptionIndex);
5555
TypeDescriptionFlags = info.Flags;
5656
IsInitialized = true;
@@ -124,7 +124,7 @@ private bool CheckIfRecursiveReference()
124124
var parent = TypedParent;
125125
while (parent.IsInitialized)
126126
{
127-
if (parent._objectAddress == _objectAddress)
127+
if (parent.ObjectAddress == ObjectAddress)
128128
return true;
129129

130130
parent = parent.TypedParent;

UnityMemorySnapshotThing/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private static void FindLeakedUnityObjects(SnapshotFile file)
130130
if (integerFieldValue.Value == 0)
131131
{
132132
var typeName = file.ReadSingleStringFromChapter(EntryType.TypeDescriptions_Name, managedClassInstance.TypeInfo.TypeIndex);
133-
Console.WriteLine($"Found leaked managed object of type: {typeName}");
133+
Console.WriteLine($"Found leaked managed object of type: {typeName} at memory address 0x{managedClassInstance.ObjectAddress:X}");
134134
numLeaked++;
135135
}
136136
}

0 commit comments

Comments
 (0)