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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:17:32+00:00 2026-06-09T06:17:32+00:00

I have referenced this link. Heap memory I have a doubt class Sample {

  • 0

I have referenced this link. Heap memory

I have a doubt

class Sample
{
    public static void main(String[] args)
    {
        Date dt=new Date();
        System.out.println(""+dt);
    }
}

First dt will be at eden space if GC happens it will go to Survivor space , if GC happend when dt is in Survivor space (correct me if am wrong).

My Question is:

  1. if date is displayed and program completes the running process then will
    these dt remains in Heap space ??
  2. If GC not occured where dt will remains ??
    (eden space, survivor space or etc)
  3. program completes the running process then dt will have no reference am i
    right??

Thank you very much …..

  • 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-06-09T06:17:33+00:00Added an answer on June 9, 2026 at 6:17 am

    if date is displayed(program completes the running process) will these dt remains in Heap space ??

    (1) When the program completes there will be nothing on heap (dt will not exist)

    If GC not occured where dt will remains ?? (eden space, survivor space or etc)

    (2) All you can say about “dt” is that it will be created in eden space, After that if it goes to survivor space or Tenured Generation or gets garbage collected is all managed by GC and you cannot exactly know where it

    program completes the running process dt will have no reference am i right??

    (3) Yes it wont have any ref. In fact when the method terminates dt will be eligible for GC (now if gc happens rt away or takes time you don’t know)

    To be clear, There are NO guarantees with GC, any memory allocated during program execution might remain allocated after program termination, in such cases it will be reclaimed by the operating system

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

Sidebar

Related Questions

I have a WPF UserControl with binding converters referenced like this: <UserControl x:Class=MyControl x:Name=MyControl
I have c#.net code which calls a method from another external/referenced .net assembly. This
I have a large non static JAVA function, which uses this reference at several
I have build a c# class library verification.dll using OpenCVSharp. This references OpenCvSharp.dll in
Say I have defined a variable like this (C++): static const char str[] =
i have a div and an anchor link in my page, and i referenced
Suppose I have some simple struct like this: public struct WeightedInt { public int
I have a doctrine class User which is of this hierarchy Doctrine_Record -> BaseUser
This seems really simple but Im brand new to JavaScript. I have a link
In reference with this question We have a header with a date picked component

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.