I was trying to track how much memory my application is taking. So I was reading /proc/self/statm
.
#include <iostream>
#include <fstream>
void print_mem(){
std::ifstream proc_stream("/proc/self/statm");
long long VmSize = 0, VmRSS = 0, Share = 0;
proc_stream >> VmSize >> VmRSS >> Share;
proc_stream.close();
std::cout << VmSize << " " << VmRSS << std::endl;
}
struct C{
int a[256];
};
int main(){
print_mem();// first call
C* c = new C;
print_mem();// second call
return 0;
}
I was expecting there will be some growth in VmSize. But What I see is it always reports same VmSize, VmRSS. shouln't it change as I've allocated c
?