Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

GC question  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True or false:
Low memory situations cause GC to run?
I read somewhere that GC only runs after the heap has been exhausted, and that when it runs, all other threads are suspended. I've somewhat confirmed this particular behavior in Sun reference implementation JVM's. Is this behavior specified by Java or JVM dependent?
Anyhow, the answer to my first question would seem to be true, but I am not sure. A related question would be 'does a heap allocation failure force gc to run'? Again I think the answer id yes, just from observing Sun's jvm.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is false.
Though it is a nice to have feature, garbage collection is not guaranteed and hence your program can run out of memory!! Remember that GC is vendor specific and may not depend on howmuch memory is left on the heap
Ajith
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i fully agree with Ajith. U can never force GC, and u can never know when it is activated, so there can b possibility of program going out of memory. So a heap allocation failure can never force gc to run.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!