Forcing System.gc()

R

Roedy Green

I am wondering if I may not be able to improve performance by System.gc() in
some "right" places in my code (wherever those might be!). It seems to me
though, that the gc facilities in Java are so good, that this is something
best left up to the JVM, and NOT mess with putting System.gc() in anyplace?

Try it. It might ignore you anyway. At worst it will go slower, and
you take them out.
 
T

Thomas Schodt

R. Vince said:
I have an app that, at one point, really bogs down as so many objects are
created and released in a lengthy process.

I am wondering if I may not be able to improve performance by System.gc() in
some "right" places in my code (wherever those might be!). It seems to me
though, that the gc facilities in Java are so good, that this is something
best left up to the JVM, and NOT mess with putting System.gc() in anyplace?

One scenario where you might get a better responsiveness
is calling gc() when a Java GUI application is minimized (or loses focus).

If you don't, imagine the OS swapping the memory out and when you switch
back to the application
one of the first things that happens is the JVM decides it needs to
do a gc run - a lot of that heap must first be swapped back in.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top