Top 3 Memory Overhead Penalties of Excessive Padding

While beneficial for cache performance, over-padding arrays can lead to significant memory waste, especially in arrays of structures, increasing the program's memory footprint, potentially causing more page faults, and reducing overall data locality by spreading data further apart.

The top 3

  1. Largest Memory Footprint Increase: Excessive padding can significantly inflate an application's memory usage, leading to higher RAM requirements and potentially increased cloud hosting costs due to larger instance types or storage needs.
  2. Reduced Data Locality for Other Structures: While intended to improve cache for one data structure, over-padding can push other critical data out of the cache, ironically decreasing overall cache hit rates for unrelated but frequently accessed parts of the application.
  3. Increased Swap Usage & Performance Degradation: When the memory footprint grows too large due to excessive padding, the operating system might resort to more frequent swapping to disk, causing significant performance bottlenecks and making the application noticeably slower.

Sources

Open the full topic