I'm trying to discover how Java manages memory.
I'm learning which part of memory holds static methods and static variables. They said PermGen memory holds static variables and static methods, which is a part of non-heap memory(picture below).
But, from what I've learnt, Java has stack segment to hold local variables, parameters, references, values of non-void function returns... etc, heap segment holds objects and arrays. I've read many many Q&A about this topic and have 2 ways to explain it:
- Divide into 2 parts: Heap & Non-heap memory.
- Divide into 3 parts: Stack segment, Heap segment, Code segment.
Who can help me to understand this more clearly. If memory is divided into 2 parts: Where's stack ? If memory is divided into 3 parts: Which part holds static methods and static variables ?
I would be grateful to get your help :D Thanks.