3 ms·
> The reality is you still have to free resources, so it's not like the garbage collector is doing work that doesn't need to be done. The garbage collector als
by boomlinde 7y ago
> The reality is you still have to free resources, so it's not like the garbage collector is doing work that doesn't need to be done.
The garbage collector also needs to track resources, which is an additional cost over just freeing them. You have little control over how the memory is allocated, which is an additional cost over a design that intelligently uses different allocation strategies for different types of resources. Then, even if you can control when the garbage collector is invoked, you have little control over what actually gets freed. What good are those 200µs if the stuff eating up memory isn't actually getting freed fast enough?
Maybe people often overestimate their performance needs. A garbage collector may be fast enough for more purposes than anticipated. Even then, managing memory intelligently may seem like a small price to pay compared to the prospect of eventually fighting a garbage collector to get out of a memory bottleneck.