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
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feature Request Reference traversal (finding the root)

Discussion in 'Profiler Previews' started by SunnySunshine, Feb 4, 2023.

  1. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    974
    When clicking a reference in the "All Of Memory" tab, you see a table to the right "Referenced By". If you click one of the items in that table, you get more information about that object, including how many objects are referencing it. However, you cannot see what those references actually are.

    My suggestion is that you can somehow traverse the references, so in a chain of references, you'd be able to find the root object. This could as simple as a button, selecting the currently selected reference, making it the "main" selection (as if it was clicked in the main view) and showing its references.
     
    alexeyzakharov likes this.
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    Hello,

    I have some questions about what you're asking, as I need further context to make sure I understand the issue right.
    To set some context, the References view should list all references to the selected item exhaustively. The root would be included in that but may not be exactly clearly distinguishable. Circular references and reoccurring items are cut from it so these items would only be listed once.

    So if there is an item in there that, when selected, shows that it has more references to it than you can unfold underneath it in the References tree, that should only happen if those references are listed elsewhere in the tree. I read your feature requests as feedback that that could be clearer? E.g. listing those items but marked clearly as reoccurring elsewhere in the tree?

    There may also be bugs here but I can't tell if that could be the case without a more concrete example.

    Marking the roots more clearly is something we know we have to add.

    Giving you the ability to select an item from the references in the main can well be a good addition regardless, but when it comes to the references among the objects in the References view I don't think that should be necessary, as they should be included, even if currently in a not very transparent way...

    Could you maybe examine your particular issue with that in mind and maybe share some screenshots so that we can get a fuller picture of the situation?
     
    alexeyzakharov likes this.
  3. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    974
    I'll be honest, I was testing the memory profiler in my 2021.3 project, and that wasn't the latest memory profiler. However, I did try memory profiler in a newer project so I can have a later version, but I'm not making that much sense of it atm, so I'm not sure I can provide useful feedback.

    Take this for example:

    Code (CSharp):
    1. public class ReferenceTest : MonoBehaviour
    2. {
    3.     public TesterA a;
    4.  
    5.     // Start is called before the first frame update
    6.     void Start()
    7.     {
    8.         a = new TesterA();
    9.         var b = new TesterB();
    10.         var c = new TesterC();
    11.  
    12.         a.b = b;
    13.         b.c = c;
    14.         b.a = a;
    15.  
    16.         var b2 = new TesterB();
    17.         a.b2 = b2;
    18.         c.test = this;
    19.     }
    20. }
    21.  
    22. public class TesterA
    23. {
    24.     public TesterB b;
    25.     public TesterB b2;
    26. }
    27.  
    28. public class TesterB
    29. {
    30.     public TesterC c;
    31.     public TesterA a;
    32. }
    33.  
    34. public class TesterC
    35. {
    36.     public ReferenceTest test;
    37. }
    If I add ReferenceTest monobehavior to an object, play the scene, capture it in memory profiler and then search for "tester", I'm not getting what I'm excepting:



    I was under the impression that each field in the "All of memory" view was an instance, but in that case there is one instance missing, since there are two TesterB instances. Furthermore, selecing any of the instances will not show the parent reference class, and every referenced to is empty which is not correct either.

    Maybe I'm not using it correctly but this is not making sense to me.

    I also noticed that of you put all the classes in the same file, you wouldn't be able to search for the tester classes at all.
     
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    Yeah, that's because the search in 1.0 does not search by type name, only by native object name. We're fixing that in 1.1.

    What you're finding here is just the native asset file connection for these managed types. If you want to find the Objects of Type TesterA/B/C in 1.0, you'll need to sort by name and scroll through the Managed objects until you find them.
     
    alexeyzakharov and SunnySunshine like this.
  5. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431