Hacker News new | ask | show | jobs
by robmaister 2825 days ago
Once you get past a certain point of developing a complex game in Unity, one of the optimization techniques is to keep runtime allocations at 0 bytes in order to prevent a GC pause from ever happening. This was a huge pain back when Unity was on Mono 2.10.8 (released Dec 2011) but it's a bit better now.

It's a fight against the GC typically

3 comments

>Once you get past a certain point of developing a complex game in Unity, one of the optimization techniques is to keep runtime allocations at 0 bytes in order to prevent a GC pause from ever happening.

It is, but it's still an option. It's not like "language with GC" == no-go for games, as the parent implied.

Unfamiliar with any game codebases or much C++, but I know in C we'd do zero-allocation or controlled arena allocation for "embedded" uses. I'd imagine Allocation tuning is always present. Was it much harder in C#?
.NET has support for stack allocation and manual management of native memory.

Many forget that MSIL is rich enough to support C++, initially via Managed C++, later replaced by C++/CLI.

The major features in C# 7.3 are related to slices, improved stack allocation and reducing copies of value types.

Just like it is a fight against malloc() if the game's architecture is not done properly.