In Nexus, memory is allocated only to objects. There is no explicit allocation of memory, there is only the creation of new objects. Nexus performs automatic memory management. Therefore, the burden of deallocating no-longer needed objects is automatically handled by the garbage collector.
The garbage collector reclaims the memory occupied by an object once it determines that object is no longer accessible. This automatic process makes it safe to throw away unneeded object references because the garbage collector does not collect the object if it is still needed elsewhere. Therefore, in Nexus the act of letting go of unneeded references never runs the risk of deallocating memory prematurely.
Nexus implements a generational mostly-copying collector. A generational collector partitions the heap according to the age of objects, and focuses its attention on younger objects. New objects are allocated in the youngest generation (often called the nursery), and are promoted to an older generation each time they survive a garbage collection. In applications where most allocated objects are short-lived (which is the case in many applications), the generational collector is efficient because most garbage collections only examine a portion of the heap (it saves time by ignoring older objects), and because the spatial locality of objects in the nursery can improve system cache use.