Okay, so I have been developing in Java for a little over a year now and am making an effort to dive deeper into the language and its best practices.
So here is what I know:
Java "passes by type" - that is primitives pass by copy and object reference pass by copy (references point to their object on the heap).
Primitive instance variables and references live in their class object in the heap and local primitives and references live on the stack (in their respective stack frame).
Perm Gen. memory space is where class meta data is stored (used for reflection).
The Heap has an Eden space where new objects are places, a Young space where objects who have survived a GC are kept and a Tenured space where long lived objects are placed.
So here is what I would like to understand:
Where do static and static final primitives and references live that the JVM is able to use a single instance?
Are static and static final objects stored in the Heap (I assume they are moved to tenured)?
What is considered the best practice in terms of the number of static final references in an application?
Will creating more static final references decrease the amount of Heap space in JVM?
I have read many different explanations about this (all differed) and would love if a seasoned veteran in the Java language could provide a good explanation. Thanks in advance!