1

I am working on a memory tracker based on jemalloc. It is used to collect basic memory stats roughly of the process by calling mallctl and prevent more upcoming requests when memory is over a threshold.

Previously I use the stats.mapped or stats.resident, but later I found out that even if some allocated memory is released, these memory were not returned to the OS even after purge or decay. All memory will be munmap when process exit. Using stats.allocated or stats.active can't get the correct result since shared memory and other usages are excluded.

My question is, how to get the memory usage of the process in RAM with jemalloc? Something like RSS in top or ps reported by OS.

Thanks!

  • Can you be more precise what you mean by "memory usage", as you indicated there are lots of interpretations. – Botje Oct 14 '20 at 11:44
  • For example, the `RES` in `top` or `ps` reported by Linux system, how much memory is in physical memory. As for tcmalloc, something like `generic.heap_size - tcmalloc.pageheap_unmapped_bytes`. – DoodleNoodle Oct 21 '20 at 11:48

0 Answers0