automatic garbage collection Flashcards
What is automatic garbage collection in Go?
A feature that automatically manages memory by reclaiming unused memory allocations.
True or False: Go uses reference counting as its primary garbage collection algorithm.
False
What algorithm does Go use for garbage collection?
A mark-and-sweep algorithm.
Fill in the blank: The Go garbage collector is designed to minimize _____ during application execution.
stop-the-world pauses
What does the ‘mark’ phase in the mark-and-sweep algorithm do?
It identifies all reachable objects in memory.
What happens during the ‘sweep’ phase of garbage collection?
Unreachable objects are deallocated or cleaned up.
Multiple choice: How does Go’s garbage collector primarily determine which objects are garbage? A) Reference counting B) Mark-and-sweep C) Tracing
B) Mark-and-sweep
What is the purpose of the garbage collector in Go?
To automatically reclaim memory that is no longer in use.
True or False: The Go garbage collector can run concurrently with the application.
True
What is ‘stop-the-world’ in the context of garbage collection?
A pause where all application threads are stopped to perform garbage collection.
Fill in the blank: The Go garbage collector is designed to achieve _____ collection times.
low-latency
What is the role of the ‘heap’ in Go’s memory management?
It is the area of memory where dynamically allocated objects reside.
How often does the Go garbage collector run?
It runs automatically based on the allocation rate and memory usage.
Multiple choice: Which of the following is NOT a feature of Go’s garbage collector? A) Automatic memory management B) Manual memory deallocation C) Low latency
B) Manual memory deallocation
What is a ‘garbage collector cycle’ in Go?
The process of identifying and reclaiming unused memory.
True or False: Go’s garbage collector can lead to memory leaks if not properly managed.
False
What is the significance of the ‘GC’ environment variable in Go?
It allows developers to control garbage collection parameters.
Fill in the blank: The Go runtime includes a _____ that provides information about memory usage and garbage collection.
garbage collection statistics
What is a ‘finalizer’ in Go’s garbage collection?
A function that is called when an object is garbage collected.
Multiple choice: What is the main goal of Go’s garbage collection? A) To improve application performance B) To prevent memory leaks C) To reduce memory usage
B) To prevent memory leaks
What triggers a garbage collection cycle in Go?
When the memory usage exceeds a certain threshold.
True or False: In Go, developers need to manually free memory for unused objects.
False
What are ‘roots’ in the context of Go’s garbage collection?
Objects that are directly accessible and serve as starting points for the mark phase.
Fill in the blank: The Go garbage collector is designed to be _____ to minimize its impact on application performance.
non-intrusive