Storage Management Approach

There are two major approaches to the task of recovering memory that has been dynamically allocated once it is no longer needed.

Some languages, such as C++ and Object Pascal, leave this task to the programmer. The programmer must explicitly tell the memory manager that a dynamically allocated value is no longer needed. The memory manager then recycles the value, using it to satisfy a subsequent request for new memory.

The alternative is known as a garbage collection system. Here the memory mangement is implicit. The memory manager constantly monitors what values are being used in the running program, and detects when a value is no longer accessible. Inaccessible values are then recovered, and recycled for later memory allocations.

Languages that use a garbage collection system include Smalltalk and Java.

[audio] [real] Text to accompany slide4, in Chapter 4 of An Introduction to Object-Oriented Programming