Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Is it possible to get the sum of the Profiler Memory 'GC Allocations per Frame'?

Discussion in 'Editor & General Support' started by MathijsF, Nov 26, 2019.

  1. MathijsF

    MathijsF

    Joined:
    Apr 21, 2017
    Posts:
    4
    As the title. I'm talking about the Profiler (Window -> Analysis -> Profiler), and in that window, the Memory one.

    What I'm looking for is to create a C# function that can take a range of frames as input (e.g. frame 161 to 326) and give me the sum of the 'GC Allocations per Frame' value from the Memory profiler.

    I know about the ProfilerDriver.GetHierarchyFrameDataView() function, but that seems to get the 'GC alloc' from the CPU Usage profiler, not the Memory profiler, and seems completely inaccurate (not to mention different from the Memory profiler data). That's why I'm looking at the Memory profiler row.

    Anybody know of a way? My end goal here is to get information (programmatically) about how much total bytes of GC allocations are happening in a certain time period.
     
    KyryloKuzyk and alexeyzakharov like this.
  2. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    What is the difference you see? We record every single GC.Alloc event and increment memory stats synchronously. Do you walk all threads for GC.Alloc events? Sounds like a bug we should fix.
    (There is no API atm to extract the GC alloc information specifically.)