CS202 Java-50
Garbage Collectors: Efficiency?
lWhy doesn’t C++ have garbage collection?
•There is price to it: run time overhead
lC++ allows objects of a class to be created on the stack, not available in Java for class objects
•These are automatically cleaned up
•Providing the most efficient way of allocating storage
lAllocating memory on the heap using new is more expensive
•We have done it in 163/202 to get experience
•But, in fact it shouldn’t be exclusively used!
•And, it requires that we allocate and deallocate our memory in C++
•But, in Java, this memory need not be deallocated
lThe main issue with garbage collection is that you never really known when it is going to start up or how long it will take
•This means there is an inconsistency in the rate of execution
•Which can be important for some real-time software problems