Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
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
Tim Cooke
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Java in General
Difference between Runtime.gc() and System.gc()
vitthal wable
Greenhorn
Posts: 16
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Can You please tell me the difference between Runtime.gc() and System.gc()
Ta Ri Ki Sun
Ranch Hand
Posts: 442
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
No difference at all.
From javadoc :
The call <code>System.gc()</code> is effectively equivalent to the call: Runtime.getRuntime().gc()
Peter Chase
Ranch Hand
Posts: 1970
1
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The difference is that you shouldn't call either of them ;-)
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Marcus Hathaway
Ranch Hand
Posts: 89
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Peter, why shouldn't you call them?
ps....thats not a loaded question, i'm interested to learn more
Robert Hill
Ranch Hand
Posts: 94
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
For starters calling .gc() does not guarantee that the gc will run at that time. It makes a "best effort" attempt and cleaning unneeded objects.
The second reason is that the gc is a resource hog. Adding the call in your code adds overhead and isn't even necessary. The GC does its job well.
The amount of times that a developer will actually need to mess with the gc or call it directly are rare.
Lasagna is spaghetti flvored cake. Just like this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
question on GC
System.gc() vs Runtime.gc()
Garbage Collection
Garbage Collection
System.gc() and Runtime.gc()
More...