3 ms·
Uh, what? C++ doesn’t have garbage collection. Did I misread this comment?
by thehardsphere 9y ago
Uh, what? C++ doesn’t have garbage collection. Did I misread this comment?
- com2kid 9y agoStill possible to have huge deallocations in C++. On top of that, C++ makes it possible to fragment memory, whereas .NET's GC can compact references. In both languages you have to be conscientious of types of allocations.
- MaulingMonkey 9y agoI've had to deal with "huge" deallocations causing stuttering before - by e.g. deferring deallocation over several frames. Deferred deallocation is also occasionally important for working around use-after-free bugs in middleware or system APIs that you don't have the source code to. Building and using the tools to track down and break up circular references, dangling pointers, leaks, visualize memory fragmentation, etc. has eaten up a lot of my time. I've considered attempting to write what would amount to a compacting GC in a C++ codebase to deal with memory fragmentation issues before - but retrofitting such a beast into an existing codebase was a huge enough undertaking, that we went for other simpler half measures instead. Being unable to control some middleware and system allocations meant any such GC would involve half measures and hacks as well anyways.
- tome 9y agoI read that as "[C#] takes some careful coding (to avoid GC stutters) but not nearly as careful as C++ [requires in general]".
- thehardsphere 9y agoThat would make more sense. I can see that now. Whether that tradeoff is the one to make probably depends a lot on what kind of game you are making.
- org3432 9y agoThe engine makes uses of shared pointers to do ref counting, and will deallocate unrefed objs for you. Additionally there is a built in asset GC system.
- WillPostForFood 9y agoUnreal C++ has garbage collection: https://wiki.unrealengine.com/Garbage_Collection_Overview https://wiki.unrealengine.com/Garbage_Collection_Overview
- pjmlp 9y agoActually C++11 has a GC API and Unreal does make use of a C++ GC.