Reading / Memory management

Making room in memory

A program needs memory for the information it is using. Eventually, space occupied by information it can no longer reach can be reclaimed.

Allocation is only the beginning

Memory management includes obtaining space, using it, and releasing it. In languages with garbage collection, part of that work happens automatically. A collector identifies memory eligible for reclamation, often by checking whether objects remain reachable through the program’s references.

Reachability is a technical condition, not an assessment of usefulness. A program can keep a reference to information that its user no longer needs. That information may stay in memory because the collector cannot infer the user’s intention.

Hypothetical example · An image preview

Imagine opening a large image in a preview panel, then closing the panel. If another part of the program still holds a reference to the image data, closing the visible panel alone may not make that data collectible. An exploration could compare the visible state with the references that remain. This invented example illustrates a distinction; it reports no measured performance or company project.

Allocate spaceUse informationReclaim eligible memory

Automatic does not mean effortless

Garbage collection does not remove the need to think about what stays reachable. It also does not guarantee immediate cleanup at a chosen moment. Other resources, such as open connections, can require their own deliberate management. When considering memory behavior, ask what is retained, what keeps it reachable, and which resources need explicit closure beyond the collector’s work.

Further reading: MDN’s guide to memory management.