Search Issue Tracker
Fixed in 0.4.3-preview.1
Votes
0
Found in [Package]
0.4.2-preview.1
Issue ID
1383114
Regression
No
[Memory Profiler] Some Snapshots do not have any Managed Objects that have Native Size, Name Object Name or Native Instance ID
This Bug was split off from Case 1381034
When grouping the Diff All Objects Table's Diff column, there is a huge difference between the Native Size of the "Deleted" Group and "New" Group that does not match the change in the breakdown bars, i.e. in this case 364.9 KB New and 285.5 MB Deleted.
Part of the reasons for the difference is down to Unity Objects (objects of Types inheriting from UnityEngine.Object) with a Managed Shell Object and a Native Object are listed twice in the All Objects Table, and each list the Native Object's size in the Native Object column, so it is essentially double counted.
Digging deeper into this snapshot, you can find Unity Objects with the same Name, e.g. the URP "Uber" Shader and material, with both a Managed Shell and Native Object, each with a Native Size in the first snapshot, but only the Native Object with the name in the second snapshot. If you search the second snapshot's All Managed Objects List for the address the Managed Shell Object had in the first snapshot, you can see it is still there, it's m_CachedPtr variable, when converted to a Hex value, still points to the Native Object's address, but it no longer has the Native Object's Name, nor size listed.
How to reproduce:
1. Open any Project
2. Install the Memory Profiler Package via Add By Name/ Add By Git URL: "com.unity.memoryprofiler"
3. Open the Memory Profiler and click Import, choose the two attached snasphots
4. Switch from Single to Compare mode and open both snapshots
5. Switch back to Single view
5. Click on the "Name" Column Header, select "Filter" and type in "Uber"
6. Click on the snapshot outlined in grey to switch to that one, repeat step 5
7. You can now switch back and forth between these two filtered views by selecting the grey outlined snapshot
Expected: You can see the Uber Shader (only 1) and Material (2 materials) instances each once as Native Objects and once as Managed Objects in both snapshots.
Actual: You can only see the Native Objects in the newer snapshot.
Note: This goes for any object inheriting from UnityEngine.Object Type: Once the Managed Shell is created, it won't be GC Collected until the Native Object is Destroyed. So if the older snapshot of the same session has the Managed Shell Object, the newer one must have it too. I.e. the Uber shader and Material here are just an example where the Shell exists in the first snapshot already. There are bound to be other examples in this snapshot or others.
Additional Steps:
1. Note the address at which the Managed Objects are located in the older snapshot. (e.g. "0x000000012f1bcb60" for one of the Materials)
2. Switch to the newer snapshot
3. Clear the Name filter, add a Filter to the Address column and paste in the address you wrote down.
Expected: You find the Manage Shell Object to the Native Unity Object, with the Name "...Uber..." and a Native Size
Actual: You find the Managed Shell Object but without a Name and 0 B Native Size
Filter Address Column to "0x000000012f1bcb60" in second snapshot
Note: This particular expression of the bug was down to a root cause that would mean that it's not just some Managed Shell Objects that have this issue, but all of them, depending on what order the Managed Field info was reported in. So to see if this root cause issue affects the reading of a particular snapshot, you can switch to the All Managed Object table and group the Native Name or Instance ID columns and would only get one group as none of these Objects have any value in these columns.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- ShadowCaster2D breaks on certain Rotation positions when Casting Source is set to PolygonCollider2D
- The options modal for which type of Tilemap to create isn't drawn when it has been previously closed until the user moves their cursor
- There are 2 Overlay Menus present in the Tile Palette Window
- Unable to change the Shadow Map resolution for lights via Inspector when 'preserveCachedShadow' is enabled
- Adaptive Probe Volumes are not loaded when Adaptive Light Probes are exported via Asset Bundles and opened on another project
Resolution Note (fix version 0.4.3-preview.1 ):
Fixed in Memory Profiler 0.4.3-preview.1