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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:59:21+00:00 2026-05-16T09:59:21+00:00

I am very confused over the time at which memory is allocated to Java

  • 0

I am very confused over the time at which memory is allocated to Java programs. Is it “partially done” when the class is loaded ? I have read class lifecycle to be loading-> linking-> initialization->unloading. Wouldn’t some memory be consumed in these processes, even though we are NOT creating object of that class ?

I am also keen to know whether the initialization step done during classloading or object creation ?

Thanks a lot !

  • 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-16T09:59:21+00:00Added an answer on May 16, 2026 at 9:59 am

    There are three things that need to happen before you can "use" an instance of a class, each one of which entails allocation of heap memory:

    1. The classes bytecodes need to be loaded and linked to resolve any static dependencies on other classes.

    2. The class needs to be initialized.

    3. An instance of the class needs to be created.

    The loading and linking of classes typically happens when you start the JVM, though it can be done "lazily" by the JVM, and it can be done dynamically; e.g. using Class.forName(...). This is when memory for the classes "code" is allocated.

    Class initialization is normally done just before the first time that the class is actually used. (The precise details are set out in the JLS). This is when memory for a classes statics will be allocated.

    Class creation happens when the new construct is used. This will also trigger class initialization for a class that has not yet been initialised. This is when memory for an instance is allocated.

    In addition to the above, at some point the JVM may run the JIT compiler to turn the bytecodes for a class into native code. When (and indeed if) this happens depends on the JVM version and the JVM launch options. JIT compilation will of course allocate memory to hold the classes compiled native code.

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

Sidebar

Ask A Question

Stats

  • Questions 495k
  • Answers 495k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Most of this is possible to do yourself. Calling the… May 16, 2026 at 11:20 am
  • Editorial Team
    Editorial Team added an answer using (SaveFileDialog dialog = new SaveFileDialog()) { dialog.Filter = "Text… May 16, 2026 at 11:20 am
  • Editorial Team
    Editorial Team added an answer This should get you most of what you're looking for:… May 16, 2026 at 11:20 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I've read a few other questions that seem similar but I'm still very confused,
I have a git repo which has a few branches - there's the master
I have a little / weird behaviour here and Im looking over internet and
I am confused about how to set this up using Cake's conventions. I have
I'm confused that how an object instance loaded by the other classloader can be
We have a C# service that has started failing in very odd ways around
I have been developing a number of components using TFrames and ModelMaker -- I've
I have a query that I am executing in C# that is taking way
Lets say I have a FirstName > MiddleName > LastName hierarchy (~10k rows, for
I am new at haskell, I have to write a program context-aware,so I thought

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.