There are a number of questions on this StackExchange about memory consumption, notably:
- How to check which process is using most memory
- How to display
top
results sorted by memory usage in real time? - How to find which processes are taking all the memory?
However, all of them seem to be driving at what's using the most memory right now. I'd like to have a workflow that tells me what's using the most memory (or perhaps the top 3 to 4 processes) over a period of time (e.g. 1 hour, 12 hours).
Is there a way to accomplish this with top
, htop
or something else?
ps aux k -%mem
to see a list of processes sorted by memory, then pipe it inawk '{print $2,$3}'
to see just the PID and memory consumption. Put all that into a log file like the linked solution:while true; do ps aux k -%mem | awk '{print $2,$3}' >> memory.log; sleep 1; done
. After a few hours you'll have an enormous text file which you can parse to bin the consumptions for different processes. Sorry this comment is so long, but I don't have time to write the parse program right now. – user1717828 Sep 14 '15 at 15:40... awk '{print $11}'
). Whichever one of us get's to tinker with this first (I might get a chance in an hour or so), we should post this as the answer :) – blong Sep 16 '15 at 17:55