1

How can I get the current total allocated memory so far (in a Linux process in C/C++ (gcc))?

Cartesius00
  • 22,610
  • 41
  • 119
  • 191

2 Answers2

1

Try parsing /proc/self/maps or /proc/$PID/maps . Look for a line marked [heap].

Robᵩ
  • 154,489
  • 17
  • 222
  • 296
0

I like Rob's answer, but here's a possible alternative. If you can afford the run time cost, you can use valgrind with the massif tool.

Alex Lockwood
  • 82,434
  • 38
  • 201
  • 248