Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

(Case 1104590) PackedMemorySnapshot: "subSystemList" detected with wrong type

Discussion in '2018.3 Beta' started by Peter77, Nov 27, 2018.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    Using the UnityEditor.MemoryProfiler API to capture a PackedMemorySnapshot, causes some fields to be detected with the wrong type.

    The following "PlayerLoopSystem" struct contains the "PlayerLoopSystem[] subSystemList" field in code.
    When capturing a memory snapshot, this field is detected as ValueType, rather than an array.

    This issue seems to occur with ScriptingBackend .NET 4 only. If ScriptingBackend is set to .NET 3.x, it causes a different issue, which I reported as Case 1104581.

    Code (CSharp):
    1. public struct PlayerLoopSystem // Located in namespace UnityEngine.Experimental.LowLevel
    2. {
    3.     public Type type;
    4.     public PlayerLoopSystem[] subSystemList;  // this field is NOT detected as array in the memory snapshot
    5.     public UpdateFunction updateDelegate;
    6.     public IntPtr updateFunction;
    7.     public IntPtr loopConditionFunction;
    8. }
    screenshot.png

    Reproduce
    • Open user attached project
    • Click Mainmenu > BugReport > Open TestCode Window
    • Click "Capture Memory" button
    Observe the text shows "PlayerLoopSystem subSystemList; // (isArray=False, isValueType=True)".


    Actual
    The "subSystemList" field is detected as ValueType.


    Expected
    The "subSystemList" field is detected as Array, which is a ReferenceType.


    Sidenode
    Why is this an issue you might think. The current information in the snapshot makes the "PlayerLoopSystem" struct look like it contains a field of a "PlayerLoopSystem" struct, thus infinite nesting. This infinite nesting causes the managed heap crawler in Heap Explorer to fail.
     
    LeonhardP and Prodigga like this.
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618