garbage collection
是做内存管理的,栈内存出了scope自己释放,堆内存要用gc。
The garbage collector identifies and deallocates unused heap memory. The garbage collector is run periodically to clean up the heap
之前还以为,c#真不用释放什么的,还不如c++自己释放,现在一堆问题。还要从头捋。
https://unity3d.com/cn/learn/tutorials/temas/performance-optimization/diagnosing-performance-problems-using-profiler-window?playlist=44069
一次释放大量,时间长
释放的时机,会有额外开销导致帧率下降
heap碎片
-
We can reduce the time that the garbage collector takes to run.
-
We can reduce the frequency with which the garbage collector runs.
-
We can deliberately trigger the garbage collector so that it runs at times that are not performance-critical, for example during a loading screen.
gc优化建议
https://unity3d.com/cn/learn/tutorials/topics/performance-optimization/optimizing-garbage-collection-unity-games