Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Profiler not reporting memory allocated by Threads

Discussion in 'Editor & General Support' started by maverick1999ro, Jan 21, 2021.

  1. maverick1999ro

    maverick1999ro

    Joined:
    Jun 16, 2018
    Posts:
    5
    Is the Profiler only showing the memory allocated on the main thread ? BeginSample() shows less memory and even the overall is less when the methods are moved inside local lambdas.

    So DoSomething() reports 1GB, but DoSomething(){ do_something_using_threads();} shows 0.5GB for example.

    (I am referring to the GC Alloc column)

    Thanks.
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,161
    The GC.Alloc column of the Hierarchy view in the CPU Usage Profiler module shows the GC allocated in the selected frame and thread. On versions pre 2019.3, that would always be the main thread. On versions >= 2019.3 there is a drop-down to select the thread the Hierarchy should show data for. In timeline view, GC.Alloc samples are bright magenta and you can see all threads next to each other.
    The Memory Profiler Module's GC Allocated in frame shows all memory allocated over all threads in this frame.
     
  3. maverick1999ro

    maverick1999ro

    Joined:
    Jun 16, 2018
    Posts:
    5
    I found the threads under Timeline-->Scripting Threads when CPU Usage tab is selected. Very nice display. However for Memory Usage tab not much is shown.

    So currently there is no way to summarize the total memory sampled by BeginSample()/EndSample() if that runs on different threads, right ?
     
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,161
    No, though there are some ideas of doing that with Profile Analyzer, no plans or eTA on that yet.
     
  5. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,161