What are the strategies for accounting for the memory consumed by a process? For example, I have a program, and in the old version its memory usage was suboptimal, and it was not released at the right time, which meant that it was kept in the distribution longer than necessary. Notice, I do not mean that he leaked. The new version of the program has reworked the algorithm, and now the memory is freed first of all in the life of the program. How can I track this? Some of the ways that come to mind are: write a malloc / new replacement library that wraps libc / libstdc ++, somehow use valgrind to do this, or try the memory used by the process using ps and plot ?
source share