• 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

Help!! Question Dan Chrisholm's garbage collection

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone explain to me about garbage collection process ??. I am really confuse. Just said like this question from Dan Chrisholm garbage collection question. How is the process actually going on??. Can someone give me know about what is going on in the memory address??.

Edited by Corey McGlone: Added Code Tags
[ March 20, 2003: Message edited by: Corey McGlone ]
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a fairly lengthy thread about this exact question.
I hope that helps,
Corey
 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All local objects are eligible for garbage collection once the method ends. Am I right in thinking so?
Thanks
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sun par:
All local objects are eligible for garbage collection once the method ends. Am I right in thinking so?


Yup.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Corey,
I went throught the Flash application that you have made and it was very good in clarifying certain things for me.
After that, I tried to apply the concepts to this example.
When we say : private I i1 = new I("A");
The object is placed on the heap and the reference i1, references that object.
So here A is placed on the heap, right?
I was also wondering if we had the statement I i1 = new I("A");in a main method instead of the class J, they would be class instance variables
. How does this affect Garbage collection.
Thank you
Pallavi
 
sun par
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
local objects are eligible for GC even though some methods might create some reference to them?
Thats rule is whenever we see a local object when the method returns its bound to be Gced. Am I right?
Thanks
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pallavi Chakraborty:

I was also wondering if we had the statement
I i1 = new I("A");
in a main method instead of the class J, they would be class instance variables
. How does this affect Garbage collection.


A variable that is declared inside of a method is a method-local variable--it is not an instance variable. An object that is referenced only by a method local reference will be eligible for garbage collection when the method runs to completion. In other words, the object becomes eligible for garbage collection when the reference is no longer in scope.
An object that is created inside of a method might also be referenced outside of the method. In that case, the object would not be eligible for garbage collection as long as the reference remains in scope.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic