My question is based on the fact that:
- Whenever we create a sub class, the superclass object is not created even if the super class constructor is invoked.
- If finalize() method is defined in subclass then super.finalize() must be called also.
That's all well and good. But When I use the jvisualjvm
(under the /bin directory of the JDK installation - I do not see any super class object instance created and that is as I expect. Superclass object is not created when we create its subclass instance.
My question: What does GC clear up on part of the super class?
If you double click and open the jvisualjvm
, you can see (if you halt your program with a Thread.sleep(forEnoughTimeToCheck_jvisualjvm)
)...you will not find the super class instance there, only the subclass...probably just the reference. So does the GC clears up the super class reference whenever it does?
I have seen many many blogs and posts on SO but I haven't seen any of them explain what GC clears up on part of super class.