Reducing Memory Allocations in a Large C++ Application
Reducing memory allocations to improve performance has been a recurrent theme for a long time. Use of abstractions comes with increased use of heap allocations. This results in a widespread low level performance overhead. Sadly, memory profilers tend to scale poorly with the size of the application and number of allocations. Heaptrack, a low overhead Linux memory profiler written by Milian Wolff, makes routine analysis of memory allocations finally practical.
In this talk, I will demonstrate how heaptrack allows us to track all memory allocations with little overhead in a large C++ application. I will classify the memory patterns observed and detail the techniques used to address them. In practice, reducing the number of allocations by several order of magnitudes can be achieved. We will make full use of modern C++ up to C++17 with a glimpse of C++20.
Arnaud Desitter is a senior software engineer based in Oxford with more than 20 years experience in scientific programming. He has worked on reservoir simulators for the last 14 years. He cycles to work, currently going through his third virtual trip round the world.