Summary

This chapter quickly went over a lot of optimization topics and ideas. You used a profiler to find the 20% of code that needs to be optimized, and then you learned about the optimizations that HotSpot performs so you don't have to. Of course, HotSpot doesn't do everything, so you learned about optimizations that HotSpot doesn't perform. Finally, you explored memory usage and the garbage collector, and you even tuned the heap so that the impact of garbage collection was almost negligible, taking only about 10ms every 10 seconds. Of course, the biggest boost from optimization you'll get is not from a computer but from your brain. More efficient algorithms, such as those using BSP trees, allow you to do some amazing tricks, but you'll need to spend time trying new ideas to get things to work. So be creative and come up with some fantastic, efficient code!