1. 1
  1.  

  2. 4

    These are by no means advanced techniques. The blog post cherry-picks a subset of suggestions from this 2013 post, some of which aren’t even specific to Java garbage collection:

    1. provide collections with expected size upon construction
    2. don’t load large files into memory
    3. use immutable objects where possible.

    A quick google search will find more shorter, yet more in-depth articles on this topic: Reduce Long GC Pauses. Regardless of general strategies, the best approach to improving performance and avoiding GC pauses is to attach a profiler like Visual VM to see how many objects are being created by each method and how much memory they are using.