Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the Unity Profiler memory Analysis problem

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to understand the problem of Unity Profiler memory analysis, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

In the process of developing games with Unity, it is critical to use Profiler to analyze memory usage. However, many developers may not be clear about the meaning of the data representation in Profiler. The editor will share with you the questions and answers related to Profiler memory analysis.

To take full advantage of the power of Profiler memory analysis, the first thing to do is to understand the meaning of the data displayed by Profiler and which modules will count the memory used in Unity's Profiler. There are still many knowledge points involved in Profiler. Today, we will first choose some common questions to answer.

1. The total memory usage seen in Unity's Profiler is not quite the same as the system memory footprint I see using other tools. Why?

The memory seen in Profiler is the memory allocation seen by the Unity engine itself. All the memory of the engine Allocation and Deallocation is recorded by the engine, so we can give the exact engine memory footprint information. However, there is still other memory that we cannot know.

For example, if the engine uses a third-party library, we cannot count the memory allocated by the library. In addition, the memory you see on mobile devices is actually much larger than Profiler, because whether it is through the Instrument of Xcode or the USS of Android, the real physical memory recorded by it consists of two parts, one is the physical memory of the real Used, and the other is the Cached physical memory. This is determined by OS, and neither Android nor iOS systems immediately reclaim resources when they are not in use, but put them in cached physical memory so that they can be loaded quickly the next time they are reused. When the system finds that App does not have enough memory, it invokes a memory killer thread at the bottom to poll the cache physical memory, which in turn cleans up memory for app. Unity Profiler records the actual physical memory currently in use, that is, the first part mentioned above. Therefore, the longer the game runs, the greater the gap between the memory allocated by Profiler and the system memory obtained through other software.

Therefore, as long as there is no memory leak in the third-party library used, we generally recommend that you only need to check the Profiler. As long as the memory in the Profile can be raised and dropped normally, then there is no problem with the memory allocated on this side of the engine.

two。 When we are working on a project, we find that sometimes the System.ExecutableAndDlls item in profiler takes up a lot. Is there any solution?

The "System.ExecutableAndDlls" item shows the sum of the execution file and the libraries invoked (physical, rendering, IO, and so on). Please don't worry about the value of this option, because many Application share these libraries, and its memory pressure on real games is very small, and it will not cause OS to Kill games because of this memory.

3. Why is it that in Simple mode in Profiler, the value of Used Total is not equal to the sum of the Unity,Mono,GfxDriver,FMOD and Profiler on the right?

In fact, in Unity, the calculation formula of Used Total is Used Total = Unity + Mono + GfxDriver + Profiler + additionalUsedMemory. The additionalUsedMemory term in the formula is not shown in profiler because it is generally 0 and is available only on certain special publishing platforms (usually Android,PC and IOS are 0). So in general, the value of Used Total is the sum of all items except FMOD. Of course, this rule also applies to Reserved Total.

4. The resources of our project mainly use AssetBundle to load resources dynamically. It is found that the PersistentManager.Remapper item in Detailed mode in Profiler takes up more time and less time. What does this item mainly do?

Remapper mainly provides persistent storage of files, including various serialized asset, project setting files, etc., and maintains the corresponding relationship between files in the file system and data in memory. So if the project uses a lot of AssetBundle, it will take up Remapper's memory before Unload the AssetBundle. While the implementation of Remapper itself uses a memory pool, its value will only increase, so in order to keep the memory occupied by Remapper at a stable value, we need to Unload each time after loading a certain number of AssetBundle, instead of calling Unload after loading all the AssetBundle at once. (such an operation is also critical to maintaining the size of the entire mono heap, because the mono heap itself only increases, not decreases.)

5. When we debug the project in Editor, we find that the memory size of the texture is twice its own size, is it because Unity takes into account the size of both memory and video memory?

In fact, this is not the reason, because Editor itself will keep a share of the memory of the texture, and profiler under Editor will take into account the size of the texture used by Editor itself, so there will be cases where the memory is doubled. We officially do not recommend debugging the performance of the project under Editor, but be sure to run the compiled project on the real machine, and then connect to profiler for debugging, only in this way can you get really accurate test data.

The above content is how to understand the Unity Profiler memory analysis problem, have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report