Summary
In this chapter, we have covered a number of ways in which we can improve the performance of our code as it relates to specific governor-constrained resources. We started by looking into improving our CPU time through improved for
loops, using maps, and reducing the number of expensive operations we undertake. This led us to see how we could improve the performance for one resource but increase the usage of another inadvertently, which we built on in the next section, covering heap size.
In the section discussing heap size, we referred back to the looping code and how we can improve heap size utilization in our loops but, again, to the detriment of our CPU time. This also led to a discussion about their difference, with some of these limits being perceived by users (time to run) and others just being internal limits (heap size and memory usage). We also discussed the use of scoping to help keep heap size down, as well as manually clearing memory, by setting variables containing...