Version: Unity 6.2 Alpha (6000.2)
Language : English
Tracking garbage collection allocations
Reference type management

Optimizing your code for managed memory

C#’s automatic memory management reduces the risk of memory leaks and other programming errors, in comparison to other programming languages like C++, where you must manually track and free all the memory you allocate.

Automatic memory management allows you to write code quickly and with few errors. However, this convenience might have performance implications. To optimize your code for performance, you must avoid situations where your application triggers the garbage collector a lot. This section outlines some common issues and workflows that affect when your application triggers the garbage collector.

Topic Description
Reference type management Optimize how you use reference types in your code.
Creating reusable code Reuse code to optimize the performance of your application.
Optimizing arrays Optimize when and how you use arrays in your code.

Additional resources


对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答
Tracking garbage collection allocations
Reference type management
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961