automatic garbage collection Flashcards

1
Q

What is automatic garbage collection in Go?

A

A feature that automatically manages memory by reclaiming unused memory allocations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False: Go uses reference counting as its primary garbage collection algorithm.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What algorithm does Go use for garbage collection?

A

A mark-and-sweep algorithm.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fill in the blank: The Go garbage collector is designed to minimize _____ during application execution.

A

stop-the-world pauses

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the ‘mark’ phase in the mark-and-sweep algorithm do?

A

It identifies all reachable objects in memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What happens during the ‘sweep’ phase of garbage collection?

A

Unreachable objects are deallocated or cleaned up.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Multiple choice: How does Go’s garbage collector primarily determine which objects are garbage? A) Reference counting B) Mark-and-sweep C) Tracing

A

B) Mark-and-sweep

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the purpose of the garbage collector in Go?

A

To automatically reclaim memory that is no longer in use.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

True or False: The Go garbage collector can run concurrently with the application.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is ‘stop-the-world’ in the context of garbage collection?

A

A pause where all application threads are stopped to perform garbage collection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Fill in the blank: The Go garbage collector is designed to achieve _____ collection times.

A

low-latency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the role of the ‘heap’ in Go’s memory management?

A

It is the area of memory where dynamically allocated objects reside.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How often does the Go garbage collector run?

A

It runs automatically based on the allocation rate and memory usage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

B) Manual memory deallocation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a ‘garbage collector cycle’ in Go?

A

The process of identifying and reclaiming unused memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

True or False: Go’s garbage collector can lead to memory leaks if not properly managed.

17
Q

What is the significance of the ‘GC’ environment variable in Go?

A

It allows developers to control garbage collection parameters.

18
Q

Fill in the blank: The Go runtime includes a _____ that provides information about memory usage and garbage collection.

A

garbage collection statistics

19
Q

What is a ‘finalizer’ in Go’s garbage collection?

A

A function that is called when an object is garbage collected.

20
Q

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

A

B) To prevent memory leaks

21
Q

What triggers a garbage collection cycle in Go?

A

When the memory usage exceeds a certain threshold.

22
Q

True or False: In Go, developers need to manually free memory for unused objects.

23
Q

What are ‘roots’ in the context of Go’s garbage collection?

A

Objects that are directly accessible and serve as starting points for the mark phase.

24
Q

Fill in the blank: The Go garbage collector is designed to be _____ to minimize its impact on application performance.

A

non-intrusive

25
What is the impact of garbage collection on the performance of a Go application?
It can introduce latencies but is optimized to be minimal.
26
Multiple choice: Which Go version introduced significant improvements to the garbage collector? A) Go 1.5 B) Go 1.10 C) Go 1.15
A) Go 1.5