• 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 in Java

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is root set in JVM in relation to garbage collection ? How is a root set calculated ?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "root set" is the set of all... roots. Imagine memory as a collection of "trees" -- objects refer to other objects, which refer to other objects. If you have a list of the roots of those trees, then you have a way of getting at every object that's "live" -- i.e., every object that should not be garbage collected. If an object isn't in a tree, then you can safely discard it.

There's a fairly simple recipe for coming up with the root set; I don't have time to look it up right now but it's in the Hotspot documentation somewhere, if not the JVM specification. Basically the root set includes all the variables in all the frames on all the stacks of all the threads, plus all the static variables of all loaded classes, plus the string pool contents. There may be other things I've forgotten, but you get the idea. It's not a difficult thing.
 
She'll be back. I'm just gonna wait here. With this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic