gc

gc

Synopsis
gc run the garbage collector
Details
The gc command manually runs the garbage collector.

In theory, it should not be necessary to use this command. The garbage collector should run automatically at the most appropriate time. (A modern garbage collector will run most efficiently when it has lots of garbage to collect, and the JVM is in a good position to know when this is likely to be.)

In practice, it is necessary to run this command:

  • to cope with GC-related issues; e.g. before running startawt,
  • when debugging the garbage collector, and
  • when doing performance-related benchmarking.