• 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

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when is garbage collector actually into action.if i use system.gc() then when it will get invoked.
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by chowdaryv:
when is garbage collector actually into action.if i use system.gc() then when it will get invoked.


All the call to System.gc() does is suggest to the thread schedular of your operating system that the Garbage Collector should run. When and if it runs is up to it so, you can't be positive when it will run.
 
Ranch Hand
Posts: 289
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no way to tell when the garbage collector will actually execute, in fact it might never execute at all.When you invoke the method system.gc(), all you are doing is suggesting,humbly so, that you would very much appreciate if the garbage collector was run.Whether and when it actually gets to run is not anything you can control.Usually the gc will run as response to a runtime request from the VM, which often times is a consequence of your program exhausting all its memory on the heap, so much so that some resources need to be released and memory be made available to your program.The exact implementation of garbage collection is platform dependent and its behaviour in general is not guaranteed.
Herbert
 
Humans and their filthy friendship brings nothing but trouble. My only solace is 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