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

Minimizing Garbage Collection

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hello Gurus,
I would like to know how can we minimize the garbage collection in Java. I know that garbage collection cannot be forced.

But still what could be the best practices to minimize or avoid garbage collection in Java???

Thanks!
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Originally posted by Vivek Jain:
But still what could be the best practices to minimize or avoid garbage collection in Java???


First think of yourself if you really want this. Without garbage collection, objects are never cleaned up, and the heap just fills up until it is full and the JVM throws an OutOfMemoryError.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
In general, you don't need to worry about garbage collection in Java. The JVM contains very sophisticated algorithms to make garbage collection as efficient as possible, and you are probably not going to gain much by trying to optimize it.

However, if you want to know all the details, have a look at this document:
Tuning Garbage Collection with the 5.0 Java[tm] Virtual Machine
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic