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:
- if date is displayed and program completes the running process then will these dt remains in Heap space ??
- If GC not occured where
dt
will remains ??
(eden space, survivor space or etc) - program completes the running process then dt will have no reference am i right??
Thank you very much .....