By DeepSource

Calling garbage collector manually does not necessarily improve performance CS-P1001


The .NET runtime ships with a GC (Garbage Collector) that is responsible for allocation and freeing up of memory as deemed necessary during an application's lifetime. It is responsible for automatically handling memory management-related tasks and preventing accidents such as memory leaks, accidental double frees, etc. Manually invoking the GC does not necessarily improve your application's performance and, in some cases, may even adversely impact the performance.

If you wish to improve your application's performance, consider measures such as:

  1. Profiling your application for in-efficient hot paths
  2. Optimizing the application by using appropriate algorithms and relevant data structures