Which of these is NOT a typical trigger for Java's garbage collector to run?
easy📝 Conceptual Q2 of 15
Java - Memory Management Basics
Which of these is NOT a typical trigger for Java's garbage collector to run?
AWhen the program finishes executing a method
BWhen the JVM runs low on heap memory
CWhen the program explicitly calls System.gc()
DWhen memory allocation fails
Step-by-Step Solution
Solution:
Step 1: Identify triggers for garbage collection
Garbage collection usually runs when the JVM runs low on heap memory, memory allocation fails, or when System.gc() is called.
Step 2: Analyze each option
Options A, C, and D are typical triggers. When the program finishes executing a method (when the program finishes executing a method) does not trigger garbage collection automatically.
Final Answer:
When the program finishes executing a method -> Option A