-
Book Overview & Buying
-
Table Of Contents
Software Architecture with C++ - Second Edition
By :
Even if you don’t have very limited memory, it’s a good idea to look at how you use it. Usually, memory throughput is the performance bottleneck of modern-day systems, so it’s always important to make good use of it. Performing too many dynamic allocations can slow down your program and lead to memory fragmentation. Let’s learn a few ways to mitigate those issues.
Dynamic allocations can sometimes cause you more trouble than just throwing exceptions when you construct objects despite not having enough memory. They often cost you CPU cycles and can cause memory fragmentation. Fortunately, there is a way to protect against it. If you’ve ever used std::string (post GCC 5.0), you most probably used an optimization called small string optimization (SSO) or small buffer optimization (SBO). This is one example of a more general optimization named small object optimization...