I'm currently working on some OJ system, and the system will give out the TIME and MEMORY usage after my program is run. I know that there is ./time
that could check out time usage, how about memory? Or is there any command that could check both?
Asked
Active
Viewed 483 times
1

CDT
- 10,165
- 18
- 66
- 97
-
1possible duplicate of [Peak memory usage of a linux/unix process](http://stackoverflow.com/questions/774556/peak-memory-usage-of-a-linux-unix-process) – NPE Jan 21 '13 at 13:09
1 Answers
2
Use valgrind
.
valgrind your_exec
When your process exit, valgrind
will output a summary of bytes allocated/freed during the execution time and how much space was still allocated just before exit
Output example:
==840==
==840== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 17 from 1)
==840== malloc/free: in use at exit: 88,940 bytes in 163 blocks.
==840== malloc/free: 376 allocs, 213 frees, 208,624 bytes allocated.

Davide Berra
- 6,387
- 2
- 29
- 50