Unreachable memory
In computer science, unreachable memory is an object or block of memory allocated dynamically where the program that allocated the memory no longer has any reference or pointer that refers to it. Informally, unreachable memory is dynamic memory that the program can not reach directly, nor get to by starting at an object it can reach directly, and then following a chain of pointer references.
In dynamic memory allocation implementations that employ a garbage collector, objects are reclaimed after they become unreachable. The garbage collector is able to determine if an object is reachable; any object that is determined to no longer be reachable can be deallocated. Many programming languages (for example, Java, C#, D, Dylan) use automatic garbage collection.
In contrast, when memory becomes unreachable in dynamic memory allocation implementations that require explicit deallocation, the memory can no longer be explicitly deallocated. Unreachable memory in systems that use manual memory management results in a memory leak.
Some garbage collectors implement weak references. If an object is reachable only through either weak references or chains of references that include a weak reference, then the object is said to be weakly referenced. The garbage collector can treat a weakly referenced object graph as if it was unreachable and deallocate it. Some garbage-collected object-oriented languages, such as Java and Python, feature weak references. (Conversely, references that prevent an object from being garbage collected are called strong references; a weakly referenced object is unreachable by any chain consisting of only strong references.)