Scala

Scala

Made by DeepSource

Calling garbage collector manually does not necessarily improve performance SC-P1008

Performance
Critical

The Java Virtual Machine (JVM) ships with garbage collector(s) that are responsible for reclaiming the heap space and freeing unused resources as deemed necessary during an application's lifetime. They are reliable, performant, well-tested and are invoked as deemed necessary. Manually invoking the GC does not necessarily improve the application's performance and in some cases may even adversely impact the performance. If you wish to improve your application's performance, consider -

  1. Profiling your application for in-efficient codepath and resource leaks
  2. Optimizing the application by using appropriate algorithms and relevant data structures
  3. Modifying the amount of heap size available to the JVM
  4. Switching to an alternative GC algorithm or using the JVM tuning options.