Originally posted by elanthis
View Post
- an average programmer using GC can be faster than an average programmer using "not managed memory" (whatever this means)
- GCs have good throughput (maybe better than the malloc/new), but for games has to be avoided
- saying about crap-loads of objects, it seems you imply that in C++ you use everywhere const-references, move semantics and such, and you spill everywhere with new in GC, and every time has to be a full blown class, or Generics list. I think you are aware that there is the struct keyword in C#. You have to use it at times, really
- GCs and realtime games probably are not the best match, but what about not-so realtime but close to realtime games? Can't they use a GC? Imagine a game like Heroes of MM, or XNA games? Do they get all the freezes or things that you state that GC are painful for?
- at last, do you know that Mono as of 3.0 has a generational GC? You can use this in your advantage (probably you did). Of course, you have to take in account the memory management algorithm (I think you do this with games, as you say that you want to use memory pools)
This looks to me like a mediocre C# programmer (or a mediocre C++ programmer would do on the same years experience):
We don't _need_ a generational GC because we don't fragment the memory space excessively or generate craploads of garbage objects in the first place. C# needs a high-end GC becuase the language requires it; some surprising basic constructs in C# generate garbage like it's going out of style.
C#:
Q: How many objects are created when you use a lambda (for Linq)? Let's say to find all objects that match a condition?
A: 1 (for closure)? If the iteration happen (it is lazily loaded), you will create the 2nd object (the Enumerator)
C++:
Q: How many copies are involved if you don't put ++ before iterators in a loop?
A: As many objects are in the loop
Sure, you never make these pitfalls, but you just expect that all C# programmers do, so this is why you can write efficient C++ code, but not fast C# code, right?
Leave a comment: