Cartesius00
Cartesius00

Reputation: 24414

Consumed memory per process

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

Upvotes: 1

Views: 219

Answers (2)

Alex Lockwood
Alex Lockwood

Reputation: 83301

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.

Upvotes: 0

Robᵩ
Robᵩ

Reputation: 168796

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

Upvotes: 1

Related Questions