• 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

GC question

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic