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

My first profile result and I'm puzzled.

Discussion in 'Profiler Previews' started by chrisk, Feb 23, 2019.

  1. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Hi, thanks for the awesome Memory Profiler. It helps hunting down where memories going.

    Here is my first profiling result and I'm trying to figure out who is allocating.
    (I created an empty scene->restart the editor->capture memory to minimize memory usage.)

    1) My project with Empty Scene
    upload_2019-2-23_19-51-45.png

    For comparison, here is the capture for New Project with just Standard Asset.

    2) New Project with Empty scene
    upload_2019-2-23_19-53-33.png

    The biggest difference is RenderTarget Texture and AnimationClip.
    In my project, there is GUIViewHDRRT related stuff and can't figure out where it's coming from. Searching from the Project folder shows nothing. And it seems to load all animation in the Project as well.

    My questions are the followings.

    1. What is GUIViewHDRRT? I can't find it on the Project. Is this Unity stuff? If so, why is it showing only on my project?

    2. Why are all AnimationClip loaded in my project? Loading all AnimationClips on launching Editor the default behavior? I hope not. If it's not the default behavior, who might be loading them?

    3. Is there a way to tell who's allocating, so that we can track them down? If not, can this feature be added? Like allocation history or something?

    Thanks.
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Hi Chris,

    This sounds like you are capturing the Editor or maybe the play-mode Player running in the Editor? Profiling the play-mode Player (for CPU or memory profiling) will result in skewered results. The Profilers can not cleanly separate between stuff happening or being loaded in memory due to the play-mode player or due to the Editor. Therefore, profiling in the Editor is there for optimizing Editor scripts and behavior and for quick iteration, not for understanding and finding issues. For that you should always profile a built player, ideally on your target device.

    Regarding your questions:
    1. GUIViewHDRRT sounds like a RenderTexture used within the Unity Editor UI, so some Editor windows you might have open or inspectors. I'd be surprised if you'd see that when you profile a built player.
    This is a good example for why profiling in the editor might mislead you to look at something that is a non-issue for your game. Similarly, "GameView RT" is the Game views output, "SceneView RT" the scene view's output, then there is some RT for the Camera Preview if you selected a camera in the sceneview... none of these will ever appear in your game.

    2. I don't know enough about the Animation system to comment on this. Maybe you selected a model with animations and the inspector loaded the mesh and animations into memory (even if there might not be an inspector window open). You should be able to look at the animations reference count, click on it and follow the chain of references to see what is holding it in memory. The thing that loaded it might be gone by now and maybe the clips will be gone after the next "UnloadUnusedAssets"...

    3. We have the list of references, which can help by showing what still keeps it in memory, and likely whoever created it is among those, but that is by no means guaranteed so, no there is no straight forward way just yet. We're looking at allowing to optionally store the call-stack for an allocation or similar means to improve on this. Besides that, we also want to providing a better way to presenting the reference chain ("Path-To-Root").

    Does this answer your questions?

    Also, thanks for trying the Memory Profiler and providing this input,

    Martin
     
  3. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Hi, Martin, thanks for the detailed answer.
    This is the capture from Editor right after Editor is loaded from the cold start, so nothing should be left over from selecting object or running the game.

    I'm very concerned about the animation because it seems to load them all on an empty scene from the cold start.
    Thanks.
     
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    What Windows do you have open? timeline? Animation or Animator view?... maybe those cause it.
    What do you get if you click their Reference count number what is holding these animations referenced?
     
  5. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Also, from what I heard it might very well just be expected behavior as your Animation Clips might be held in memory by their importer, so that they can be used. I.e. if you have an animation file with multiple sub clips in it as sub-assets, those sub-assets need to be created, so that they can be used in the editor.

    It's similar to another question raised in this sub-forum about Sprites and the Sprite Atlas they are in, being both loaded in memory in the editor. For Editor purposes, both the bundled data and the separate data need to be in memory. If this for some reason becomes a problem for you, that might be something to raise as a bug so that the people working on these areas can see if memory load in the editor can't be reduced somehow.
     
  6. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Yes, I had the Animator window open. I guess it load all animation when Animator is open. Expected behavior is to open only reference animations clips but I guess not.

    What do you mean?
    You mean the number in Animation Clip (1079)?
    It just shows sub-tree view on animation clips. It doesn't show who is referencing it.
     
  7. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    No, I mean clicking on any item in that sub tree and then in the list underneath the tree view there is a Column named Ref Count with a number in blue that you click on to see the x number of things that reference this AnimationClip.

    I guess you could close that window, reopen and capture again. It could still very much be the case that everything still is in memory due to the way the asset importer works but I have no special insight into that area, nor the importer for AnimationClips.
     
  8. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Oh, nice. I can see who is referencing. The most of the AnimationClips are referenced by BlendTree. (didn't check all)
    I can't tell which BlendTree it is though.