Chapter 4. Precious memory: Space efficiency

This chapter covers

  • Writing space-efficient classes
  • Comparing the memory requirements of common data structures, including arrays, lists, and sets
  • Assessing trade-offs between performance and memory footprint
  • Exploiting memory locality to improve performance

Sometimes, programmers need to store their data in as little space as possible. Contrary to intuition, this rarely happens because the device they’re targeting comes with little memory. Rather, it happens because the amount of data is huge. For example, video games are a type of software that often pushes the limits of the hardware. No matter how many GB of memory the next console boasts, soon games will run out of it and start packing data ...

Get Seriously Good Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.