• 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:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

Garbage Collection

 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all
can anyone tell me If the following are true or false....
1> The programmer can signify through a reference that an object is no longer needed (and does this necessarily mean that the object will be garbage collected).
2> The GC can happen at any time and without any particular order
3>Does the GC prevent you from running out of memory
regards
pranav
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Its the garbage collector that decides for itself if
an object is not needed. You can set all reference to an
object to null to make sure that when the garbagecollector
looks at it will consider it eligible.
2. That's right you don't know when garbage collection will
happend and there is no order to it.
3. It's suppose to but there is no guarantee.
You can't be suure that a large object that using up
all your memory will be garbage collected before
you create 10 more. The other thing I read is that
there is this problem that java programers face on some
String intensive programs. They say that String
literals don't realy ever get garbage collected.
At least one copy stays in the pool forever.
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders
https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing
reply
    Bookmark Topic Watch Topic
  • New Topic