This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Garbage Collection

 
Ranch Hand
Posts: 207
3
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My question is->



When line doStuff is reached there is only 1 Object eligible for Garbage Collection. Why???
 
author
Posts: 23878
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

O Shea wrote:
When line doStuff is reached there is only 1 Object eligible for Garbage Collection. Why???



Perhaps it would help is you told us how many objects should be eligible for GC, and why? This way, we can give you a hint based on where you went wrong.

Henry
 
O Shea
Ranch Hand
Posts: 207
3
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since I am reading from Kathy Sierra , Bert bates and it is written that there is still a reference to the object referred to by a2 , and there is still a reference to the object referred to by a2.b2 .

We can still access other Beta object through the static variable a2.b1-bcz its static //Can't understand this
 
Henry Wong
author
Posts: 23878
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

O Shea wrote:
We can still access other Beta object through the static variable a2.b1-bcz its static //Can't understand this



The b1 variable of the Alpha class, is a static variable. This was set via "a1.b1=b1" in the example... but it doesn't need the a1 reference to reach it. Since this variable is a static variable, it can still be reached via "Alpha.b1".

Henry
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

O Shea wrote:When line doStuff is reached there is only 1 Object eligible for Garbage Collection. Why???


I'm pretty sure this topic will answer every possible question you have about this question

Hope it helps!
Kind regards,
Roel

PS1. If you use a code snippet, a quote, a code example from another resource, you must QuoteYourSources (in your original post).

PS2. Always use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information. Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers. I already added the code tags for you. See how much easier the code is to read?
 
O Shea
Ranch Hand
Posts: 207
3
Oracle MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you next time will take care about time
 
Don't MAKE me come back there with this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic