Skip to content

Commit 2c58c5c

Browse files
committed
Fixed C# empty shell object detection. It didn't work with memory snapshots captured from a Player, but from an Editor only. See https://forum.unity.com/threads/heap-explorer-memory-profiler-debugger-and-analyzer-for-unity.527949/page-6#post-8240496 for details. Thanks to Gotmachine for the fix.
1 parent be172be commit 2c58c5c

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this package are documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [4.1.1] - 2022-06-29
8+
### Fixed
9+
- Fixed that ```#C Empty Shell Objects``` detection didn't work with memory snapshots taken from a Player. Thanks to Gotmachine for the fix, see [this post](https://forum.unity.com/threads/heap-explorer-memory-profiler-debugger-and-analyzer-for-unity.527949/page-6#post-8240496) in the Unity forums for details.
10+
711
## [4.1.0] - 2022-06-28
812
### Added
913
- Added ```#C Empty Shell Objects``` view. It's basically a native Unity object that was destroyed, where its managed object representation is still hanging around, which seems to indicate some sort of memory leak. See [this forum post](https://forum.unity.com/threads/heap-explorer-memory-profiler-debugger-and-analyzer-for-unity.527949/page-5#post-5896832) for more details.

Editor/Scripts/ManagedEmptyShellObjectsView/ManagedEmptyShellObjectsControl.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ protected override void OnBuildTree(TreeViewItem root)
5050
// Get type as a "higher level" representation that is easier to work with
5151
var richType = new RichManagedType(m_Snapshot, obj.managedTypesArrayIndex);
5252

53-
// Try to get the m_InstanceID field
53+
// Try to get the m_InstanceID field (only exists in editor, not in built players)
5454
PackedManagedField packedField;
55-
if (!richType.FindField("m_InstanceID", out packedField))
56-
continue;
57-
58-
// The editor contains various empty shell objects whose instanceID all contain 0.
59-
// I guess it's some kind of special object? In this case we just ignore them.
60-
var instanceID = memoryReader.ReadInt32(obj.address + (ulong)packedField.offset);
61-
if (instanceID == 0)
62-
continue;
55+
if (richType.FindField("m_InstanceID", out packedField))
56+
{
57+
// The editor contains various empty shell objects whose instanceID all contain 0.
58+
// I guess it's some kind of special object? In this case we just ignore them.
59+
var instanceID = memoryReader.ReadInt32(obj.address + (ulong)packedField.offset);
60+
if (instanceID == 0)
61+
continue;
62+
}
6363

6464
// Check if we already have a grouping node for that type.
6565
// Create a new node if we don't have it.

0 commit comments

Comments
 (0)