# Unreachable memory

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Unreachable_memory
> Markdown URL: https://mediated.wiki/source/Unreachable_memory.md
> Source: https://en.wikipedia.org/wiki/Unreachable_memory
> Source revision: 1117863331
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Block of memory allocated by a program which has lost all references to it}}
{{Redirect|Unreachable|the [John Frusciante](/source/John_Frusciante) song|Unreachable (song)}}
{{More citations needed|date=October 2015}}
{{Use dmy dates|date=October 2022}}

In [computer programming](/source/computer_programming), '''unreachable memory''' is a [block](/source/Block_(data_storage)) of [dynamically allocated memory](/source/dynamic_memory_allocation) where the [program](/source/computer_program) that allocated the memory no longer has any reachable [pointer](/source/pointer_(computer_programming)) that refers to it. Similarly, an '''unreachable object''' is a dynamically allocated [object](/source/object_(computer_science)) that has no reachable [reference](/source/reference_(computer_science)) to it. Informally, unreachable memory is [dynamic memory](/source/dynamic_memory) that the program cannot 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](/source/garbage_collection_(computer_science)), 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](/source/Dynamic_memory_deallocation). Many [programming language](/source/programming_language)s (for example, [Java](/source/Java_(programming_language)), [C#](/source/C_Sharp_(programming_language)), [D](/source/D_programming_language), [Dylan](/source/Dylan_(programming_language)), [Julia](/source/Julia_(programming_language))) 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](/source/memory_leak).

Some garbage collectors implement [weak reference](/source/weak_reference)s. 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 '''{{visible anchor|weakly reachable}}'''. The garbage collector can treat a weakly reachable [object graph](/source/object_graph) as unreachable and deallocate it. (Conversely, references that prevent an object from being garbage collected are called ''strong references''; a weakly reachable object is unreachable by any chain consisting only of strong references.) Some garbage-collected [object-oriented](/source/Object_oriented_programming) languages, such as [Java](/source/Java_(programming_language)) and [Python](/source/Python_(programming_language)), feature weak references.  The [Java package](/source/Java_package) <code>[java.lang.ref](/source/java.lang.ref)</code> supports soft, weak and phantom references, resulting in the additional object reachability states '''softly reachable''' and '''phantom reachable'''.

Unreachable memory (in languages, like C, that do not reclaim) is often associated with [software aging](/source/software_aging).

== External links ==
* {{cite web |last=Nicholas |first=Ethan |url=http://weblogs.java.net/blog/2006/05/04/understanding-weak-references |title=Understanding Weak References |publisher=java.net |date=4 May 2006 |access-date=1 October 2010 |archive-url=https://web.archive.org/web/20100819115659/http://weblogs.java.net/blog/2006/05/04/understanding-weak-references |archive-date=19 August 2010 |url-status=dead }}

{{Memory management navbox}}

Category:Automatic memory management

---
Adapted from the Wikipedia article [Unreachable memory](https://en.wikipedia.org/wiki/Unreachable_memory) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Unreachable_memory?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
