I have a code where I need to save RAM usage so I've been tracing RAM usage through tracemalloc.get_traced_memory
. However, I have found that what tracemalloc.get_traced_memory
gives is very different from the RAM usage I see through htop
. In particular, the usage appearing in htop
is more than twice than the usage returned by tracemalloc.get_traced_memory[1]
(which is supposed to return the peak
value). I wonder why this is happening, and what would be a more accurate way to trace RAM usage other than tracemalloc.get_traced_memory
?
Ubuntu 20.04.4 LTS python version: 3.7.15