Search Unity

Everything you need to know about Memory Profiler 1.0.0

January 30, 2023 in Engine & platform | 10 min. read
Unity, branded image with no logo
Unity, branded image with no logo

Is this article helpful for you?

Thank you for your feedback!

The new Memory Profiler – version 1.0.0 – delivers improvements to the profiling suite that offer a more complete view of memory usage and make it easier and faster to optimize performance or detect memory issues.

We in the profiler team are very happy to announce that, as of September 2022, the Memory Profiler package moved from Experimental to Verified and is now accessible for everyone using the Unity 2022.2 Tech Stream.

Memory Profiler: An overview

Optimizing memory is crucial for applications that run on devices with limited capabilities in order to prevent them from crashing out of memory. Moreover, if you’re planning to ship on multiple devices, your memory footprint might be in need of fine tuning to make sure you get the best out of each platform.

The Memory Profiler is a tool that helps you with these challenges by allowing you to take a snapshot of your game and review its memory usage at a specific moment in time.

By taking a “snapshot” of your game, you can see what is occupying most of its memory or identify problems that might cause applications to crash.

Note: While Memory Profiler’s complete features and memory tracking are only available for 2022.2 onwards, you can take advantage of the new user interface (UI) to inspect older captures by opening Memory Profiler in an empty 2022+ project and importing older snapshots.

How it got here

Memory Profiler was originally released as an experimental package a couple of years ago, but this release includes a major overhaul of the UI and user experience (UX) to make it faster and easier to use.

The original experimental package was used by some early adopters, and helped in many cases to identify memory issues. However, it was unwieldy, slow, and required expert knowledge in its first iteration.

When we set up to work on a new version of the package, we had the following intentions in mind:

  • Simplify the most common and important workflows, so that you would be able to identify and fix issues faster
  • Provide more complete and reliable information to make it easier to compare memory usage across devices (also using platform-specific profilers) 
  • Showcase information in a more accessible way, so that users without in-depth knowledge of memory can still effectively optimize applications

To achieve this, we’ve been working closely with the early adopters of the experimental package in order to understand their needs and pain points, and we have iterated several times on the design to make sure it provides the best UX possible.

Thanks to their input, our team was able to greatly streamline and simplify the tool, reducing jargon and making it easier to inspect objects, details, and dependencies directly in the tool.

What’s inside

Memory Profiler consists of three main sections that showcase its new and improved UI, which we’ll break down here:

  • Snapshot list 
  • A Main section, which is itself divided into three workflow views (Summary, Unity Objects, and All of Memory)
  • Selection Details

Snapshot list

The Snapshot list is the area where you can capture and see snapshots that you have taken in your game, as well as high-level information about memory usage and date of capture. Here, you can capture snapshots either with the “Capture” button in the toolbar or – if no snapshot is available – through the snapshot button in the Main section.

You can also see whether memory usage is changing across snapshots and can get a sense of whether project performance is improving or not.

Finally, you can also use Snapshot list to select whether you want to look at single snapshots or compared snapshots (more information about this below).

Snapshot list
Snapshot list view

The Main section

This is the core area of Memory Profiler, divided into three workflow views: Summary, Unity Objects, and All of Memory. Each of these views is accessible from the tabs in the top of the Main section.

The Summary view is the default view that opens as you load or capture a snapshot. It provides information on how much memory you are using, how much is “resident” on the device, and how much is committed but not currently on device. It also provides information about how memory is distributed across categories, to simplify choosing where to start your investigation.

Finally, Summary view provides entry points for more detailed analysis, such as the “Top Unity Objects in Memory” or the “Managed memory breakdown.”

Main section – Summary view
Main section – Summary view

The Unity Objects view is where you will likely spend the most time. It lists all the main types of objects loaded in memory, such as textures, shaders, fonts, and so on. Usually, this is where you can identify objects that are too big, don’t need to be there because they have been loaded mistakenly, or were kept in memory by some hanging reference.

Main section – Unity Objects view
Main section – Unity Objects view

The All of Memory view enables you to see all memory, divided by category – Native, Managed, Graphics, or Executables. You can see the data captured by the Memory Profiler and investigate more specific aspects to see what is composing your project’s memory.

Main section – All of Memory view
Main section – All of Memory view

Selection details

Selection details offers more information about items selected in the Main section, including descriptions of different categories of memory and potential references or details of selected objects.

This section offers more information to help you understand what you are looking at, and makes it easier to determine why it is in memory. Moreover, if you have the project open in the Editor, you will have the possibility to “ping” objects and inspect assets directly in the Scene or Project window.

 Selection details view
Selection details view

Comparing snapshots

Each of the views described above is available for inspecting single snapshots or for comparing them.

If you want to compare a snapshot, you can select “Compare” in the snapshot list, then select a second snapshot from your list. Being in the compare tab of the snapshot list will automatically turn all views into Compare mode.

In Compare mode, the Summary view provides the two captures’ memory breakdown, side by side, so you can see the main differences in memory usage between the snapshots (which will be named “A” and “B”).

Compare mode view
Compare mode snapshot

In the Unity Objects and All of Memory views, there is a new, dedicated UI that allows you to see how different memory categories have changed in size or the amount of objects contained in them.

If you select a category in the top table, you will be able to inspect individual differences for snapshot A and B in the tables below.

Unity Objects and All of Memory views using Compare mode
Unity Objects and All of Memory views using Compare mode

If you want to go back to inspecting a single snapshot, you can select “Single” again in the snapshot list. The second snapshot will stay latently loaded so you can quickly switch between the two, as needed.

Understanding memory in Unity and how to optimize it

In the coming months, we hope to provide you with further resources and information on how you can effectively optimize memory. Stay tuned for more blog posts covering how to identify common problems in memory, as well as a deep dive into how memory works in Unity.

For more general resources on how to optimize application performance, we recommend the following: 

Next steps

This redesign of the Memory Profiler integrates input from many early adopters of the experimental version of this package. While this version brings major improvements in both the reliability and usability of this tool, our work is far from done.

We are also currently working on better understanding workflows related to reducing fragmentation, so that we might be able to help you with this aspect in the future. At the same time, we are gathering feedback on usability and UX issues that are still open and need improvement.

If you have any feedback or suggestions, we invite you to share your thoughts through our roadmap page, where you can vote for existing features in progress or suggest new ones. You can also reach out to ask questions in the forums.

We’re constantly monitoring both channels and look forward to working together to further improve Unity’s performance and tooling.

Install or learn more about the Memory Profiler 1.0.0 package.

This content is hosted by a third party provider that does not allow video views without acceptance of Targeting Cookies. Please set your cookie preferences for Targeting Cookies to yes if you wish to view videos from these providers.

January 30, 2023 in Engine & platform | 10 min. read

Is this article helpful for you?

Thank you for your feedback!

Related Posts