how to measure memory
I was wondering if there exists a function to measure memory on linux OS for a given c++ function. So, what i have is a situation where a person claims that some function he/she wrote needs 20n words of memory to do something. however this function is quite complex and calls some other functions and so on. So i was hoping that there is a way to measure roughly if the memory statement is correct or not.
So my question is: is something like that possible? Is there a function that i can call to see how much memory was consumed during its execution.
where as a result I would get a memory consumption peak for this function
mem-measure_stat( functio(input) );
cout << mem-measure_stat() << endl;
Before and after memory state?
Statistics of Malloc - The GNU C Library
Hook malloc and free to track usage while the function is being called.
The GNU C Library