20,741
edits
mNo edit summary |
|||
| Line 2: | Line 2: | ||
Garbage collection is a common approach to automatic memory management in programming languages. In a garbage collector, the runtime system automatically identifies which objects are no longer in use by the program and reclaims the memory used by those objects. This can help prevent memory leaks and make it easier for programmers to manage memory in their programs. | Garbage collection is a common approach to automatic memory management in programming languages. In a garbage collector, the runtime system automatically identifies which objects are no longer in use by the program and reclaims the memory used by those objects. This can help prevent memory leaks and make it easier for programmers to manage memory in their programs. | ||
The mark/sweep collector is one type of garbage collector. It works by first "marking" all objects that are currently in use by the program, then "sweeping" through memory and reclaiming any objects that were not marked. This can help prevent memory leaks, but it can also cause performance issues because the mark/sweep process can be expensive in terms of computational time and can cause stuttering or non-deterministic behavior in the program. | |||
== mark/sweep GC == | == mark/sweep GC == | ||
A mark/sweep garbage collector is a type of automatic memory management system that is commonly used in programming languages that lack built-in support for garbage collection. The basic idea behind a mark/sweep garbage collector is to periodically scan through the program's memory and identify any blocks of memory that are no longer being used by the program. These blocks of memory, known as garbage, are then freed up for use by the program. | A mark/sweep garbage collector is a type of automatic memory management system that is commonly used in programming languages that lack built-in support for garbage collection. The basic idea behind a mark/sweep garbage collector is to periodically scan through the program's memory and identify any blocks of memory that are no longer being used by the program. These blocks of memory, known as garbage, are then freed up for use by the program. | ||