• 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

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any way to FORCE garbage collection? I have put some calls to System.gc() in my code but (as I expected) the system sees the call but keeps chugging (no garbage collection)
Any help would be greatly appreciated.
Kris
 
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can request the system to do a garbage collection, but there is no guarantee that it will happen. You can't force it.
Dale

------------------
By failing to prepare, you are preparing to fail.
Benjamin Franklin (1706 - 1790)
 
Kris Decker
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, then that lends the question:
How do programs such as JProbe force garbage collection when you click on the garbage collection button?
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not familiar with JProbe. But according to the JVM specs, GC can not be forced, It can only be suggested. You can ask the GC to execute, but it's up to the JVM when, and if at all, the GC runs.


------------------
Bosun
SCJP for the Java� 2 Platform
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Presumably, rather like a debugger, JProbe taps into interfaces (JPDA, JVMPI ...?) that let it do stuff inside the JVM that a normal program cannot. You wouldn't want to have a normal application attempt to use such interfaces.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sometimes when you know you're done with the object, just set it to null. But still there is no guarantee that anything will force gc.
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is it that you are actually trying to achieve by running the garbage collector, there is most likely an easier and more reliable way than using the gc.
Dave

Originally posted by Kris Decker:
Is there any way to FORCE garbage collection? I have put some calls to System.gc() in my code but (as I expected) the system sees the call but keeps chugging (no garbage collection)
Any help would be greatly appreciated.
Kris


 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic