Priting Memory related Info


Is it possible to print memory related info in the code.
i mean
int main()
can i print memory consumed now
int* i = new int[8]
can i print memory consumed here ..
return 0;

Please let me know your thoughts on this

Getting resource usage is highly system dependent.

A call to getrusage(2) returns lots of per process resource utilizations. You may be interested in ru_idrss which "returns an integral value of the amount of unshared memory residing in the data segment of a process (expressed in units of kilobytes * ticks-of-execution)" (From man page).

Another way may be to find memory allocation in your systems /proc directory.
Topic archived. No new replies allowed.