• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic