Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why is Garbage Collection Necessary for Object-Oriented Programming?

0
10 Posted

Why is Garbage Collection Necessary for Object-Oriented Programming?

0

Michael Spertus Geodesic Systems mps@geodesic.com There are several reasons why true object-oriented programming requires garbage collection. 1. Manual Memory Management Breaks Encapsulation. Program components frequently need knowledge of an entire program to determine the last use of an object and provide deletion. This makes reuse of the component nearly impossible. For example, methods and functions taking a container as an argument need to know of or make assumptions about the rest of the program to determine ownership of the objects in the container. Attempts to encapsulate memory management with reference counting, the “poor man’s garbage collector”, are usually misguided. Reference counting has worse performance than GC, awkward syntax, and poor semantics, which typically include failure to reclaim cycles, inability to handle stack and static objects, lack of polymorphism, and problems with interior pointers (e.g. arrays and multiple inheritance). Intensive research [1] in garb

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.