How can I get the current total allocated memory so far (in a Linux process in C/C++ (gcc)
)?
Asked
Active
Viewed 172 times
1

Cartesius00
- 23,584
- 43
- 124
- 195
-
Within your own program? Or outside (then maybe using `htop` or similar tools)? – phimuemue Jun 05 '12 at 19:40
2 Answers
1
Try parsing /proc/self/maps
or /proc/$PID/maps
. Look for a line marked [heap]
.

Robᵩ
- 163,533
- 20
- 239
- 308
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
- 83,063
- 39
- 206
- 250