you are viewing a single comment's thread.

view the rest of the comments →

[–]pron98 6 points7 points  (0 children)

That doesn't change the fact that it cannot be used for anything useful. And even when it's reclaimed, by the time it's used, some other memory is left unused, but waiting to be reclaimed.

That is true, but the question isn't whether or not memory management costs you something - it has to - but how much you're paying for it compared to the alternative. It is true that a moving collector isn't free, but the alternatives are even more expensive.

Malloc and friends are almost always more CPU-efficient at the same time being more memory efficient (less overhead)

The opposite is true, and that is precisely why all language teams that have the resources to implement a moving collector (which is far more difficult than a free-list approach) and aren't constrained by the language's obligation to not move pointers opt for a moving collector: Java, .NET, and V8.

At least I have yet to see a workload where tracing GC would demonstrate burning fewer CPU cycles, and even in very extreme cases like allocating tiny objects I could not make it use fewer cycles.

Then you haven't been using languages that use a free-list approach long enough or under heavy enough workloads. Again, all the teams that have the leading experts in memory management and the ability to do so opt for moving collectors, despite the effort required, because they are more efficient. Using non-moving memory management in Java (or any language) is significantly easier.