Measuring memory usage in Python: it’s tricky
pythonspeed.com
pythonspeed.com
[0]: https://github.com/plasma-umass/scalene [1]: https://www.youtube.com/watch?v=nrQPqy3YY5A
If your goal is to find peak memory usage, which is what you care about in data processing batch processes, Fil is probably a better choice (https://pythonspeed.com/fil).
On the time profiling side I highly recommend py-spy and pyflame (a little less updated).
The question "how much free memory do I have" or "how much memory does this program use" is a very hard one, and you can't just read the "MemAvailable" column from /proc/meminfo or RSS/PSS/Virt from ps/pmap.
Don't mix up SI and binary prefixes, kids! The listing shows 3083 MiB, which is either 3.01 GiB, or 3.23 GB. There's no mainstream interpretation giving 3.08 of something.
The weird power-of-two prefixes get the special weird symbol and name, because you wouldn't want those anywhere except computing.
I think this might help me immensely. Thank you OP.
There are no great tools for getting the common data out yet as far as I know, but the possibility is there and the standard dtrace / usdt hooks are in place. You can use it with bpftrace.