Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7576857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:01:34+00:00 2026-05-30T17:01:34+00:00

Okay, so I have been developing in Java for a little over a year

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:01:36+00:00Added an answer on May 30, 2026 at 5:01 pm

    The young space includes the eden space and survivor spaces.

    Where do static and static final primitives and references live that the JVM is able to use a single instance?

    Its not defined, but in the Sun/Oracle JVM, static fields live in a special object for class fields. You have one instance per class loader so static fields can have multiple instances.

    Are static and static final objects stored in the Heap (I assume they are moved to tenured)?

    In the Sun/Oracle Java 7 they are. They could be in the Perm Gen or any where else.

    What is considered the best practice in terms of the number of static final references in an application?

    Keep them to a minimum.

    Will creating more static final references decrease the amount of Heap space in JVM?

    If you can change a final field into a static final field, this can save some space (if you have multiple instances) However, clarity is usually more important than performance. (And I would do it for clarity)

    BTW: I have been developing in Java for 13 years.

    So there can be multiple instances of static fields – does the JVM alter each instance

    They are independent. Each classloader can load its own version of a class (the code doesn’t have to be the same) and each gets its own static fields (they don’t have to be the same either)

    if a static field is changed (ie. static int instanceCount where instanceCount++ is executed on each object construction)?

    No.

    Also, Objects can be moved to Perm Gen?

    No. Must some data which is not defined in one location can be anywhere depending on the implementation and version.

    Is Perm Gen. considered to be part of the Heap?

    It is part of the old gen = tenured + perm gen.

    Young gen = eden + survivor space * 2

    Maximum Heap Size limits the young gen & tenured total. Perm gen and direct memory have their own limits. Memory mapped files done follow any of these limits.

    This is true for the default parallel collector and the concurrent mark sweep.

    The G1 collector doesn’t divide up the spaces the same way.


    Links for more details

    http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html

    Java heap terminology: young, old and permanent generations?

    http://javarevisited.blogspot.com/2011/04/garbage-collection-in-java.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay. Now I give up. I have been playing with this for hours. I
Okay so I have been trying to get into IoC lately. However, I keep
Okay I have been trying to get this to work for some time now.
Okay guys I have a database I have been working on for days now.
Okay so I have been developing a system so far in main memory that
Okay so i have been working on this app for a couple months now
Okay, I have been messing with this autocomplete stuff for 2 weeks now, and
Okay, so I've been getting into 2D game developing/programming , and many games I've
Okay so basically, i have been trying this for and hour or 2 now.
Okay, So I have been all over the net trying to find ways to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.