Originally posted by ciplogic
View Post
When programming in a native environment you are allocating directly from the system (which has logic in place to limit fragmentation but not by moving memory around which again is terribly expensive). You are not maintaining your own heap (unless you actually want to, just like with a managed language you can setup your own heap by just allocating a large chunk of ram and create your own custom allocator/deallocator).
As for the garbage collector itself, it also eats cpu/ram for it's logic of deciding when data falls out of scope and when it is time to start garbage collecting, now in recent years there's been alot of work put into lowering this overhead but it's overhead nonetheless which does not exist in manual memory management where the programmer explicitly tells the system when and where to reclaim memory.
I'm not on the 'garbage collecting is evil'-train, I think it helps making it easier for the programmer and helps prevent memory leakage due to bugs, BUT it does come with a cost in performance. Whether the benefits outweigh the downsides is up to you and in practice likely varies from project to project. As always there's are no silver bullets in programming.
Leave a comment: