How to avoid Garbage Collection

Overview

The unpredictability of Garbage Collection can be a serious issue for some applications. You can play with the tuning parameters, but the simplest approach is to create less garbage.

Low garbage application

For low latency trading system, minimising GC time is important. The extreme case is avoid GCs all together.

If you reduce the garbage produced and increase your Eden size you can reduce your GCs to once per day (as an over night task) In the case of this application the Full GC triggered at 5 am every morning takes 1-2 seconds (during the overnight maintenance window)

It should be possible to extend the period between GCs to once a week.

Related articles

Using primitives instead of wrappers

Using primitives and collections which support them

More to come ...

Comments

  1. Absolutely correct mate and if it comes to garbage string is number one because of its immutability :). I have also blogged about garbage collection java some time back. let me know how do you find it.

    Javin

    ReplyDelete
  2. Are you doing anything other than System.gc() to call the collection during the maintenance window? How often does the JVM follow your suggestion to collect?

    ReplyDelete

Post a Comment

Popular posts from this blog

Java is Very Fast, If You Don’t Create Many Objects

System wide unique nanosecond timestamps

What does Chronicle Software do?