DEV Community

Cover image for How Can Unity Developers Identify GC Stutters, Lua Leaks, and Mono Memory Issues with GOT Online?
GameOptim
GameOptim

Posted on

How Can Unity Developers Identify GC Stutters, Lua Leaks, and Mono Memory Issues with GOT Online?

Summary

Investigating game performance issues often requires developers to connect CPU execution costs, garbage collection (GC) activity, Lua function calls, and Mono heap memory usage. GameOptim's GOT Online provides analysis capabilities across Overview, Lua, and Mono modes to help development teams identify performance bottlenecks and investigate memory-related problems.

This article introduces several improvements to these modes, including GC call-frequency monitoring, CPU call-stack visualization, reverse Lua call-stack analysis, Lua leak investigation caused by Mono references, and more detailed Mono heap allocation and object-reference analysis. These features help developers move from observing performance symptoms to examining the functions, objects, and memory changes behind them.

How Can You Detect Frequent GC Calls in Unity?

Garbage collection (GC) activity is one of the important indicators to examine when investigating game stuttering. To help developers monitor GC call frequency, GOT Online has added GC statistics to the loading module in Overview mode.

GC call frequency is influenced by heap memory allocation. When functions allocate more heap memory, or allocate it more frequently, GC can be triggered sooner.

If GC.Collect is called frequently, as illustrated in the image above, developers should investigate the allocation behavior of the functions involved. This is particularly important when GC calls become increasingly frequent as the game runs longer.

In such cases, developers can use GameOptim GOT Online's Mono mode to investigate whether Mono memory is being allocated too quickly or in excessive quantities. This helps connect observed GC activity with potential heap allocation issues that warrant further analysis.

How Can You Identify CPU Performance Hotspots More Quickly?

GOT Online has improved the CPU call-stack analysis page to make it easier to understand execution-time trends and identify functions that contribute to CPU workload.

The CPU execution-time chart displays the overall execution-time trend alongside the trends for top functions. By comparing these curves, developers can quickly identify which functions may be contributing to execution-time peaks.

CPU execution-time trends and top functions in GOT Online

This visualization makes it easier to examine changes in CPU execution time and investigate which functions are associated with unusually high values.

Detailed CPU function execution-time analysis in GOT Online

The updated page also supports scene-specific analysis. Developers can navigate to a particular scene and examine the execution-time distribution of individual functions within that scene.

This makes it easier to narrow the investigation to the relevant scene instead of relying only on aggregated CPU performance data.

How Can Reverse Call-Stack Analysis Help Identify Lua Performance Issues?

Reverse analysis is one of the useful features in GOT Online's Lua mode because it helps developers trace memory allocation back through function relationships without repeatedly expanding deep call stacks.

In reverse-analysis mode, expanding a node displays a list of direct parent functions that call the function represented by that node and generate heap allocations. By following these relationships, developers can trace the allocation back toward the functions responsible for it.

Reverse call-stack analysis in GOT Online Lua mode

This approach reduces the need to navigate deeply nested call stacks one level at a time and helps developers narrow down the underlying allocation source more directly.

The latest version also adds self-time percentage to the stack information for a selected frame. This metric helps developers identify functions that account for a larger proportion of the execution time within the analyzed stack.

Self-time percentage in Lua frame stack information

By examining self-time percentage alongside the existing stack information, developers can more easily identify functions that deserve closer investigation when analyzing performance costs.

How Can You Investigate Lua Memory Leaks Caused by Mono References?

Lua memory leaks caused by Mono references are another important area of investigation in GOT Online's Lua mode.

In the latest version, GOT Online improves how Mono objects are presented during leak analysis. Developers can inspect detailed information about Mono objects on a single page, including the number of destroyed objects and how that number changes over time.

Mono object details for Lua leak analysis in GOT Online

The comparison mode also allows developers to compare different sampling points and examine whether the observed memory changes are reasonable.

By reviewing object details, destruction counts, and changes between samples, developers can investigate potential Lua leaks associated with Mono references and determine which changes require further analysis.

How Can You Understand Where Mono Heap Memory Is Being Used?

High Mono memory usage can be difficult to investigate because memory problems can arise in different ways. Developers need to understand not only how much memory is occupied, but also where that memory is being used.

GOT Online's latest Mono mode improves the presentation of heap memory leak analysis, making it easier to investigate why Mono memory usage is high and how the memory is distributed.

Mono heap memory usage and leak analysis in GOT Online

The visualization provides an overview of Mono memory usage, helping developers examine the memory distribution and identify areas that warrant closer investigation.

How Can You Trace Mono Heap Memory Back to Specific Functions and Variables?

GOT Online provides additional details at both the function and memory-sample levels to help developers investigate Mono memory usage.

The function view displays the actual heap memory usage associated with each function during game execution. This helps developers examine which functions are associated with memory consumption.

Function-level Mono heap memory usage in GOT Online

Developers can also select any bar in the chart below to inspect details about actual heap memory usage and the variables residing in memory at that sample.

Within the Mono object reference view, developers can select any two memory samples from the bar chart and compare their memory changes. This comparison helps them identify specific functions associated with memory growth and investigate the corresponding memory increments and variables.

By tracing changes across sampling points, developers can narrow down potential sources of memory leaks and gather more specific information for further debugging and remediation.

What Should Unity Developers Take Away?

  • Monitor GC call frequency: Use GC statistics in Overview mode to investigate frequent GC.Collect calls and potential excessive heap allocation.

  • Use CPU execution-time trends: Compare overall CPU costs with top-function trends and inspect specific scenes to narrow down performance hotspots.

  • Trace Lua allocations through reverse analysis: Follow parent-function relationships to investigate allocation sources, and use self-time percentage to identify functions with higher execution costs.

  • Compare Mono object samples: Examine object details, destruction counts, and changes between sampling points when investigating Lua leaks caused by Mono references.

  • Trace Mono memory to functions and variables: Use function-level heap memory data and comparisons between memory samples to investigate memory growth and potential leak sources.

FAQ

Q1. How can developers investigate frequent GC calls in Unity?

Developers can use the GC statistics in GOT Online's Overview mode to examine GC call frequency. If calls become increasingly frequent during gameplay, they can use Mono mode to investigate whether heap memory allocation is occurring too quickly or in excessive quantities.

Q2. How does GOT Online help identify CPU performance hotspots?

Overview mode displays overall CPU execution-time trends alongside trends for top functions. Developers can examine execution-time peaks, investigate the functions associated with those peaks, and use scene-specific analysis to inspect function execution-time distributions within individual scenes.

Q3. What is reverse analysis in GOT Online's Lua mode?

Reverse analysis displays direct parent functions that call a selected function and generate heap allocations. Developers can follow these function relationships to trace allocations toward their sources without repeatedly navigating deeply nested call stacks.

Q4. How can developers investigate Lua leaks caused by Mono references?

Developers can inspect Mono object details, including destruction counts and their trends, in GOT Online's Lua leak analysis. They can also compare sampling points to investigate memory changes and determine whether the observed increments warrant further investigation.

Q5. How can GOT Online help investigate Mono memory leaks?

Mono mode provides function-level heap memory usage, detailed information about memory usage at selected samples, and the variables residing in memory. Comparing two sampling points in the Mono object reference view helps developers investigate memory increments and identify functions and variables associated with potential leaks.

Top comments (0)