I'd like to track how much memory various programs touch while in specific states. For instance, say I have a graphical program. It might use substantially less memory when it's minimized, since it won't redraw the window, which requires reading images and fonts and executing a large number of library functions. These objects are still accessible in memory, but they aren't actually being used.
Tools like top
are of limited use since they just tell how much memory is mapped into a program's address space, and how much of it is resident in physical RAM. Likewise, leak detectors will only tell when memory is inaccessible, not if if it just isn't being used.
Is there an existing tool that can track actively used / unused memory in this way? If possible, I'd like to track usage not only on the heap but also in memory storing program/library code.
EDIT: I'd like to clarify: I want to know much much memory a program actually reads, writes, or executes after a certain point, i.e., once it reaches a certain state. While the number of pages in the address space and the number of resident pages are important measurements, this is not what I'm looking for.
I'm pursuing three approaches right now:
This can be derived from data in /proc/pid/smaps. This breaks out an RSS value for each mapped area (including stack, text/data, and anonymously mapped regions), so you can see exactly what is resident for each loaded object as well as stack and heap.
Some links that might be helpful:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With