Memory has many different facets, with no one being primary. Even the seemingly simple question “How much memory is my program using?” does not have a single obviously correct answer. There is the amount of memory your program has obtained from the system via
malloc and the amount the process (including
malloc) has obtained from the operating system. Both of these are really address space, not memory, so there is the question of how much of that address space is backed by real memory. In addition, you have mapped files and lots of address space and memory that is shared between processes, mostly by the system.
Furthermore, the operating system is trying its best to optimize memory usage given the current set of ...