|
GCs can be faster, but it comes at a cost of less memory efficiency. Deallocing a section of memory takes the same time whether you're doing it manually or automatically. At the end of the day calling free takes the same time whether your program is calling it, or whether a GC is calling it.
But a GC can delay freeing memory until a time when the processor is idle, or until it has a big chunk of memory which it can free all in one go. A GC could even free memory before it goes out of scope, as long as it knows that that memory won't be referred to again. It could also try to anticipate your memory usage, perhaps keeping a little on the side just in case you need it.
Generally speaking, a good GC trades memory for CPU. Sometimes this is a good thing; having something run 5% faster at the cost of 5% extra RAM may be worth it. At other times, it may not be. Also, no GC can make a perfect trade-off all of the time, so if you're unlucky you may find yourself with more memory and more processing time.
Also, KISS should really be KIASAPS - Keep It As Simple As Possible, Stupid.
|