(Case 1115544) Array type 'baseOrElementTypeIndex' does not point to its element type

Using the UnityEditor.MemoryProfiler API to capture a PackedMemorySnapshot, causes some array types to be detected with a missing element type.
This issue seems to occur with ScriptingBackend .NET 4 only.

The element type of the array "int[ ]", would be "int".
The MemoryProfiler API in uses the "baseOrElementTypeIndex" of the "int[ ]" type, to point to the "int" type.
In some cases, this does not seem to work.

Screenshot [spoiler]4080229--355924--screenshot.png [/spoiler]


  • Open user attached project
  • Click Mainmenu > BugReport > Open TestCode Window
  • Click "Capture Memory" button

Various array types found with the message "Array '' has no element type".

Array types should provide a baseOrElementTypeIndex to figure out its element type.

Update: Link to bug-report in issue tracker https://issuetracker.unity3d.com/issues/packedmemorysnapshot-array-type-baseorelementtypeindex-does-not-point-to-its-element-type

Hi Peter! When we collect types from mono we exclude uninitialized ones / unused. Meaning if I got a class A{} and then a array A[ ] a = new A[n]; (here the type is A[ ] and not A, it does not require A) as long as type A is not used the inner type is not initialized. This can happen even for more complex containers such as Dictionaries where some of the inner types will not be initialized if the Dictionary itself does not have any elements added. We will be changing this behavior to output all types in the coming versions of Unity.

[quote=“alexrvn”, post:2, topic: 727869]
We will be changing this behavior to output all types in the coming versions of Unity.
Do you know if the behavior has been changed to output all types? The bug-report was closed as “By Design” though.

The issue is reproducible with Unity 2019.4.9f1 on some platforms. Perhaps the fix is available in newer versions?

Happy to know which versions will support the change.

Just as a short term update: Alex is still on vacation and I'm not certain enough.


in 19.4.10+ we changed the memory profiler to forcefully expand the types that we get form the VM(mono/il2cpp), that means that the above shouldn't occur in any cases including int[ ][ ][ ], int[ ][ ]. Could you give it a spin?