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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:37:25+00:00 2026-05-17T15:37:25+00:00

I have been lately reading a lot on memory allocation schemes in java, and

  • 0

I have been lately reading a lot on memory allocation schemes in java, and there have been many doubts as I have been reading from various sources. I have collected my concepts, and I would request to go through all of the points and comment on them. I came to know that memory allocation is JVM specific, so I must say beforehand, that my question is Sun specific.

  1. Classes (loaded by the classloaders) go in a special area on heap : Permanent Generation
  2. All the information related to a class like name of the class, Object arrays associated with the class, internal objects used by JVM (like java/lang/Object) and optimization information goes into the Permanent Generation area.
  3. All the static member variables are kept on the Permanent Generation area again.
  4. Objects go on a different heap : Young generation
  5. There is only one copy of each method per class, be the method static or non-static. That copy is put in the Permanent Generation area.
    For non-static methods, all the parameters and local variables go onto the stack – and whenever there is a concrete invocation of that method, we get a new stack-frame associated with it.
    I am not sure where are the local variables of a static method are stored. Are they on the heap of Permanent Generation ? Or just their reference is stored in the Permanent Generation area, and the actual copy is somewhere else (Where ?)
  6. I am also unsure where does the return type of a method get stored.
  7. If the objects (in the young generation) needs to use a static member (in the permanent generation), they are given a reference to the static member && they are given enough memory space to store the return type of the method,etc.

Thank you for going through this !

  • 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-17T15:37:26+00:00Added an answer on May 17, 2026 at 3:37 pm

    First, as should be clear to you by now that there are very few people who can confirm these answers from first hand knowledge. Very few people have worked on recent HotSpot JVMs or studied them to the depth needed to really know. Most people here (myself included) are answering based on things they have seen written elsewhere, or what they have inferred. Usually what is written here, or in various articles and web pages, is based on other sources which may or may not be definitive. Often it is simplified, inaccurate or just plain wrong.

    If you want definitive confirmation of your answers, you really need to download the OpenJDK sourcecode … and do your own research by reading and understanding the source code. Asking questions on SO, or trawling through random web articles is not a sound academic research technique.

    Having said that …

    … my question is Sun specific.

    At the time this question was asked, Sun Microsystems had ceased to exist. The question was therefore Oracle specific. AFAIK, all current (non-research) 3rd-party JVM implementations are either direct ports of an OpenJDK release or descended from another Sun/Oracle release.

    The answers below apply to Oracle Hotspot and OpenJDK releases, and probably to most others as well … including GraalVM.

    1) Classes (loaded by the classloaders) go in a special area on heap : Permanent Generation.

    Prior to Java 8, yes.

    As of Java 8, the PermGen space has been replaced with Metaspace. Loaded and JIT-compiled classes now go there. PermGen no longer exists.

    2) All the information related to a class like name of the class, Object arrays associated with the class, internal objects used by JVM (like java/lang/Object) and optimization information goes into the Permanent Generation area.

    More or less, yes. I’m not sure what you mean by some of those things. I’m guessing that “internal objects used by JVM (like java/lang/Object)” means JVM-internal class descriptors.

    3) All the static member variables are kept on the Permanent Generation area again.

    The variables themselves yes. These variables (like all Java variables) will hold either primitive values or object references. However, while the static member variables are in a frame that is allocated in the permgen heap, the objects/arrays referred to by those variables may be allocated in any heap.

    4) Objects go on a different heap : Young generation

    Not necessarily. Large objects may be allocated directly into the tenured generation.

    5) There is only one copy of each method per class, be the method static or non-static. That copy is put in the Permanent Generation area.

    Assuming that you are referring to the code of the method, then AFAIK yes. It may be a little more complicated though. For instance that code may exist in bytecode and/or native code forms at different times during the JVM’s life.

    … For non-static methods, all the parameters and local variables go onto the stack – and whenever there is a concrete invocation of that method, we get a new stack-frame associated with it.

    Yes.

    … I am not sure where are the local variables of a static method are stored. Are they on the heap of Permanent Generation ? Or just their reference is stored in the Permanent Generation area, and the actual copy is somewhere else (Where ?)

    No. They are stored on the stack, just like local variables in non-static methods.

    6) I am also unsure where does the return type of a method get stored.

    If you mean the value returned by a (non-void) method call, then it is either returned on the stack or in a machine register. If it is returned on the stack, this takes 1 or two words, depending on the return type.

    7) If the objects (in the young generation) nees to use a static member (in the permanent generation), they are given a reference to the static member && they are given enough memory space to store the return type of the method,etc.

    That is inaccurate (or at least, you are not expressing yourself clearly).

    If some method accesses a static member variable, what it gets is either a primitive value or an object reference. This may be assigned to an (existing) local variable or parameter, assigned to an (existing) static or non-static member, assigned to an (existing) element of a previously allocated array, or simply used and discarded.

    • In no case does new storage need to be allocated to hold either a reference or a primitive value.

    • Typically, one word of memory is all that is needed to store an object or array reference, and a primitive value typically occupies one or two words, depending on the hardware architecture.

    • In no case does space need to be allocated by the caller to hold some object / array returned by a method. In Java, objects and arrays are always returned using pass-by-value semantics … but that value that is is returned is an object or array reference.


    For more information, please refer to these resources:

    • Class metadata: a user guide
    • What is the difference between PermGen and Metaspace?
    • Java 8: From PermGen to Metaspace
    • About G1 Garbage Collector, Permanent Generation and Metaspace
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been reading up a lot about transactional memory lately. There is a bit
I have been reading a lot about Reinforcement Learning lately, and I have found
I have been reading a lot on design patterns lately and some of them
I have been reading a lot of Javascript lately and I have been noticing
Lately I have been reading a lot of blog topics about big sites(facebook, twitter,
My background is primarily as a Java Developer, but lately I have been doing
What java GUI layout manager does everyone use? Lately, I have been using MigLayout
I have been researching and playing with functional programming lately, solely to broaden my
I have been thinking quite a bit here lately about screen scraping and what
I have been trying to learn more about lambda expressions lately, and thought of

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.