


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















structures only.
package dataStructures; class SimulatedNode {
next; // constructors not shown }
c a e d b 14 c a e d b 14 0 11 8
next element 0 1 2 3 4 5 8 11 14 firstNode = 4
Linked system (Java or simulated pointer) requires:
The system determines which nodes/memory are not in use and returns these nodes (this memory)to the pool of free storage. This is done in two or three steps: Mark nodes that are in use. Compact free space (optional). Move free nodes to storage pool.
c a e d b firstNode c a e d e Start at firstNode and mark all nodesreachable from firstNode. Repeat for all reference variables.
Move all marked nodes (i.e., nodes in use) to one end of memory,updating all pointers as necessary. c b e d b firstNode a e d Free Memory
Advantages Of Garbage Collection
Advantages Of Garbage Collection
Provide a method to free/deallocate a node. e.g., delete method of C++ Now free nodes are always in storage pool.
a b c d e null firstNode
/** memory management for simulated pointer classes / package dataStructures; import utilities.; public class SimulatedSpace1 { // data members private int firstNode; SimulatedNode [] node; // package visible // constructor and other methods come here }