4 ms·
GC will most likely never be used in demanding games. You want total control over memory. 1ms sounds ok but still you don't know when and for how long the GC is
by Thaxll 6y ago
GC will most likely never be used in demanding games. You want total control over memory. 1ms sounds ok but still you don't know when and for how long the GC is going to kicks in.
- BenoitP 6y ago> for how long the GC is going to kicks in. 1ms (max, average at 50us) And for the 'when' I'll add that the very concept of having a concurrent GC means you don't need to do a (potentially pausing) malloc right in the middle of what you're trying to do.
- monocasa 6y agoThe kind of people that care about GC pause times have their own allocators that are as cheap as jvm allocations and cheaper deallocation. They aren't poopooing GC's and then just calling regular malloc and free.
- Thaxll 6y agoEngines rely on smart allocator and memory pool, they usually allocate everything beforehand. You're not running malloc between two frames. Imagine a game like Battlefield if you were to allocate memory for each fired bullet.
- CJefferson 6y agoThe biggest engine in gaming, Unity, uses c#, which is GCed.
- Thaxll 6y agoIt's def not the biggest, it's almost not used in "AAA" games also.
- liamkf 6y agoUnreal also has a GC to deal with. I've spent more time on AAA games than I'd like to admit trying to hide/mitigate/optimize the hitch.
- bitmapbrother 6y agoI would say Unreal is the biggest game engine in terms of pervasiveness. Also, isn't C# just used as a scripting language in Unity? All of the heavy lifting is dome by the C/C++ backend.
- TylerE 6y agoUnity is way way way way more common than Unreal. Unreal is more common than it was 5 years ago, but it's still a very distant 2nd. Probably 9/10 games released on Steam in 2021 are Unity. You may not realize it, since the devs are slightly less bad at hiding the fact thay they're using Unity. (How did anyone at Unity ever think that disaster of a "launcher" was a good idea?)
- pjmlp 6y agoUnreal uses a GC for Blueprints and C++ entities.
- thu2111 6y agoYeah. These "you can't use GC in games" comments always crack me up. https://docs.unrealengine.com/en-US/ProgrammingAndScripting/ProgrammingWithCPP/UnrealArchitecture/Objects/Optimizations/index.html https://docs.unrealengine.com/en-US/ProgrammingAndScripting/... "Garbage collection in Unreal Engine 4 is fast and efficient, and has a number of built-in features designed to minimize overhead, such as multithreaded reachability analysis to identify orphaned Objects, and unhashing code optimized to remove Actors from containers as quickly as possible." I always feel like there are a LOT of posers in every HN/reddit discussion of GC who have tricked out gaming rigs and are desperate to max it out in every game they play, but aren't actually game developers themselves. Whilst out in the real world there is Unreal, Unity, heck even Minecraft all making mad coin using garbage collectors at their core.
- pjmlp 6y agoHN is mostly full of FOSS and Web development culture. Coming from the demoscene and having had a foot on game development, I am fully aware that stuff like monetizing IP and getting a game published no matter what and how, are much more relevant in the game development communities than whatever gets discussed over here. Just look at e.g. the general opinion about Flash around here, and how it was embraced by the game development comunities. On Reddit there are gamedevelopment forums where you will have more luck finding more real life experience. Then there is IGDA, Gamedev, Gamasutra, Making Games, PAX, IGF and similar forums. Fact is, not every game engine needs to be used for a Far Cry clone, and there are many ways to make money.
- terramex 6y agoAnd the amount of man-hours collectively spent on working around this terrible, terrible GC is immense. It was the worst GC implementation I've seen in my life, could cause 0.5s GC spikes every 10 seconds on Xbox One even though we were allocating none or very little memory during gameplay. The amount of pre-allocated and pooled objects was bringing it down to its knees, because Unity's GC is non-generational and checks every single object every time. In the end we moved a lot of the data into native plugins written in C++. Nothing super hard, but you choose high-level engine to avoid such issues. I've read that in 2019 they finally added incremental mode GC, that solves some of the issues but is still far cry from modern GC's.