Junior — Middle
Can you list the main types of memory used in the Java platform?
sobes.tech AI
Answer from AI
The main types of memory in the Java platform include:
- Heap — a memory area for dynamic object allocation. Managed by the garbage collector.
- Stack — used for storing local variables and method calls of each thread.
- Method Area — stores information about classes, static variables, constants.
- PC Register — stores the address of the currently executing instruction.
- Native Method Stack — used for calling native methods (e.g., in C/C++).
Example: when creating an object with new String(), memory is allocated in the heap, and local variables referencing this object are stored in the stack.