I understand that each thread has its own stack
. Primitive types and references are kept on the stack, and that no object is kept on the stack.
My questions are:
Xms
and -Xmx
)As you say, local variables and references are stored on the stack. When a method returns, the stack pointer is simply moved back to where it was before the method started, that is, all local data is "removed from the stack". Therefore, there is no garbage collection needed on the stack, that only happens in the heap.
To answer your specific questions:
Source: Stackoverflow.com