2 ms·
If you really are doing hard realtime--absolutely no dropped frames, hard limit of 11ms per frame every time. Then you basically have to program in a way that c
by learc83 7y ago
If you really are doing hard realtime--absolutely no dropped frames, hard limit of 11ms per frame every time. Then you basically have to program in a way that completely avoids GC. Or use an incremental GC that you run when you have time.
So many things in C# use heap memory that you are programming in C# but without most of the advantages. Why use it over C++ or C?
Also if you take a look at DOTS, there's quite a lot that would be very hard to replicate yourself if you are using Unity.
And yes object pooling is a good best practice. But it negates a lot of the advantages of having a GC in the first place, and it's a lot easier for someone to accidentally allocate memory in C# without realizing it. Unity has a lot that I take advantage of, so I deal with avoiding GC. However if I was using my own engine, I wouldn't use C#. Despite the fact that I love C#.