0

I measure process's memory to use following command

ps -eo size,pid,user,command --sort -size | head -n 3

Then process's memory is increased. But I use free command don't increase computer's total memory usage.
some people use ps command with size keyword but other people use ps command with rss & vsz keywords.

How can I measure process's actual memory usage?

webnautes
  • 13
  • 3
  • 1
    Does this answer your question? [Problem usage memory in C](https://stackoverflow.com/questions/5994543/problem-usage-memory-in-c) – Ken Y-N Oct 14 '20 at 07:57
  • @KenY-N I use shared_ptr, is this same mechanism? don't return memory block to OS? – webnautes Oct 14 '20 at 08:42
  • Yes, the underlying implementation is often just `free()`. [This answer](https://stackoverflow.com/a/47061458/1270789) says there is a [`malloc_trim()` function](https://man7.org/linux/man-pages/man3/malloc_trim.3.html) that will try to return memory back to the OS, but I've never tried it out. – Ken Y-N Oct 14 '20 at 12:40

0 Answers0