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 1100733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:55:36+00:00 2026-05-17T00:55:36+00:00

Is a static final directly allocated into young gen or old gen or perm

  • 0

Is a “static final” directly allocated into young gen or old gen or perm gen? (I guess it will most likely land into old gen over the time I suppose.) If it is allocated in the perm gen then, will it be garbage collected when class unloading takes place in Perm Gen ?

  • 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-17T00:55:37+00:00Added an answer on May 17, 2026 at 12:55 am

    Is a “static final” directly allocated into young gen or old gen or perm gen?

    An object referenced by a static final variable will be allocated according to the same rules as any other object. It is most likely to be allocated in the young generation, or in the old generation (if it is large and certain other conditions apply).

    The object will be allocated by new executing in some arbitrary code. The JVM is not in a position to know that the object will (eventually) be assigned to a static final variable.

    The space for the frame containing the static variables is probably allocated in permGen. Of course, this is not a regular Java object.

    If it is allocated in the perm gen then, will it be garbage collected when class unloading takes place in Perm Gen?

    That depends on whether the permGen is garbage collected. In modern JVMs it is, and I would expect that the objects referenced by an unloaded classes statics would be garbage collected in the same GC cycle, or the next one … assuming they were unreachable.

    Either way, you should not code your application to depend on any of these details. They are JVM specific.


    Note that as of Java 8, this questionis moot since permgen is no more.

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

Sidebar

Related Questions

I've seen examples like this: public class MaxSeconds { public static final int MAX_SECONDS
I'm trying to pass the following String to a PreparedStatement : private static final
Is it possible to access a constant value (i.e. a public static final variable
public static Logger getLogger() { final Throwable t = new Throwable(); final StackTraceElement methodCaller
The Java static compiler (javac) inlines some static final variables and brings the values
I have a class structure such as following for storing static final constants: public
In one of my class I have the following code: private static final Color
I have the following (Java) code: public class TestBlah { private static final String
It seems logical to do some optimization around static final constants ( e.g. replace
Static metaprogramming (aka template metaprogramming) is a great C++ technique that allows the execution

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.