Lably
Skip to content

Garbage (computer science)

Unused memory in a computer system

  • 6 min read
  • 4 chapters

Related on Lably

Through Computer science, Data and Object (computer science)

Classification

Garbage is generally classified into two types: syntactic garbage, any object or data which is within a program's memory space but unreachable from the program's root set; and semantic garbage, any object or data which is never accessed by a running program for any combination of program inputs. Objects and data which are not garbage are said to be live.

Casually stated, syntactic garbage is data that cannot be reached, and semantic garbage is data that will not be reached. More precisely, syntactic garbage is data that is unreachable due to the reference graph (there is no path to it), which can be determined by many algorithms, as discussed in tracing garbage collection, and only requires analyzing the data, not the code. Semantic garbage is data that will not be accessed, either because it is unreachable (hence also syntactic garbage), or is reachable but will not be accessed; determining the latter requires code analysis, and is in general undecidable.

Syntactic garbage is a (usually strict) subset of semantic garbage, as it is entirely possible for an object to hold a reference to another object without ever using that object.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Computing and communication