Garbage Collection Flashcards

1
Q

What are the low pause garb collectors.

A

Because the phase where they scan for unused objects can occur without stopping application threads, CMS and G1 are called concurrent low pause collectors.

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

What is the default GC if none are defined on the command line.

A

The throughput collector

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

What is the command line option for enabling CMS GC?

A

XX:+UseConcMarkSweepGC XX:+UseParNewGC

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

How is CMS GC different from standard throughput GC?

A

Instead of stopping the application threads during a full GC, CMS uses one or more background threads to periodically scan through the old generation and discard unused objects. This makes CMS a low-pause collector: application threads are only paused during minor collections, and for some very short periods of time at certain points as the background threads scan the old generation.

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

What are the trade offs to using CMS GC?

A

The trade-off here comes with increased CPU usage: there must be adequate CPU available for the background GC thread(s) to scan the heap at the same time the application threads are running. In addition, the background threads do not perform any compaction, which means that the heap can become fragmented. If the CMS background threads don’t get enough CPU to complete their tasks, or if the heap becomes too fragmented to allocate an object, CMS reverts to the behavior of the serial collector: it stops all application threads in order to clean and compact the old generation using a single thread.

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

What type of use is G1 GC best suited for?

A

The G1 (or Garbage First) collector is designed to process large heaps (greater than about 4 GB) with minimal pauses.

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

How is G1 different from CMS ?

A

Because the old generation is divided into regions, G1 can clean up objects from the old generation by copying from one region into another, which means that it (at least partially) compacts the heap during normal processing. Hence, a G1 heap is much less likely to be subject to fragmentation though that is still possible.

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

What is the command line for enabling G1 GC?

A

-XX:+UseG1GC

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

What factors determine the use of CMS or throughput collectors?

A

Batch jobs with application threads that utilize most of the CPU will typically get better performance from the throughput collector. Batch jobs that do not consume all the available CPU on a machine will typically get better performance with a concurrent collector.

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

When is CMS likely to outperform G1?

A

As a basic rule of thumb, CMS is expected to outperform G1 for heaps that are smaller than 4 GB.

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

What is the main factor determining the length of a GC?

A

The time spent in GC pauses is dependent on the size of the heap, so as the size of the heap increases, the duration of those pauses also increases.

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

What command param will set the number of threads used for GC ?

A

-XX:ParallelGCThreads= N

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

What app can provide a summary of GC behavior from the GC log?

A

GC Histogram reads in a GC log and provides several charts and tables about the data in that log.

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

What command line tool can provide GC stats?

A

jstat provides nine options to print different information about the heap; jstat options will provide the full list. One useful option is gcutil , which displays the time spent in GC as well as the percentage of each GC area that is currently filled.

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

What are the garbage collectors available.

A

serial collector (used for single-CPU machines),
throughput (parallel) collector,
concurrent (CMS) collector,
G1 collector.

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