I'm attempting to reduce the memory footprint of a C++ application. Over time this application's use of memory has grown due to developers creating new, duplicate representations of data in memory for various purposes.
I'm would like to determine how frequently these duplicitous representations of data are accessed so that I can decide whether or not to make them short-lived and create-on-access in order to reduce peak heap size.
So my question is - what is the best way to track not only the size and volume of memory allocations, but also the frequency and volume of accesses to heap memory? I know that all basic memory profilers handle allocation info - correlating that to memory accesses is what I'm interested in.
An ideal answer would be platform independent, as this application runs on Windows, Linux, iOS, and Android. However, I'll accept answers which work on any of those platforms and for any processor architecture commonly used by those platforms, as we don't have platform-specific behaviour which should impact this sort of thing.