Junior — Middle
What is considered the primary mechanism for automatic memory cleanup in most modern JVM environments?
sobes.tech AI
Answer from AI
The main mechanism for automatic memory cleanup in most modern JVMs is the Garbage Collector (GC).
GC automatically tracks objects in memory that are no longer used by the program (no references to them) and frees the memory they occupy. This helps prevent memory leaks and simplifies resource management.
An example is the Mark-and-Sweep algorithm, where all accessible objects are first marked, and then memory occupied by unmarked (unnecessary) objects is freed.