• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Garbage Collection??

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

The below statement is from here

Misconception Number One: A Reference to Oneself

One big misconception is that an object that maintains a reference to itself will not protect itself from being junked by the garbage collector. Some programmers place a reference to the object as a member variable, hoping that it will count. Let me assure you that it does not. Remember that an object already has an implicit reference to itself via the

this

keyword. Unless an object is referenced by other objects, which are in turn referenced, it does not satisfy the rule.

Guys can anyone help me to realize the above statement through code?? In particular I'm not able to follow the line in bold...Anyone please??
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

One big misconception is that an object that maintains a reference to itself will not protect itself from being junked by the garbage collector.



I think that the not in this sentence should not be there.

Suppose you put your finger on your nose. That's not going to prevent you from being washed away if you fall into the river and are not tied to the riverside.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Barry, are they trying to say, an object which has reference to itself is Garbage Collected?? How can I realize this through code?? Can you please provide me with an example?
 
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Suppose you put your finger on your nose. That's not going to prevent you from being washed away if you fall into the river and are not tied to the riverside.



Interesting...
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The class has a member of the class's type that points to itself:


The objects of Ego are the noses, the ego variable is the finger.

Look at this self-reference as the smallest possible island of isolation.

On my system it prints three times "ouch" showing the ego objects are finalized.
(results of call to System.gc are system dependent)


Yours,
Bu.
[ December 18, 2006: Message edited by: Burkhard Hassel ]
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bu for the code realization of the statement that I posted.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic