Junior — Middle
In which segment of JVM memory are created objects placed?
sobes.tech AI
Answer from AI
In JVM, objects are created in the heap. The heap is a memory area designated for the dynamic allocation of objects during program execution.
The heap is usually divided into several generations:
- Young Generation — for newly created objects.
- Old Generation — for objects that have survived several garbage collection cycles.
Example: when calling new in Java, an object is allocated in the heap, and the garbage collector is responsible for freeing memory when the object becomes inaccessible.