Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ function memory usage

Name: Anonymous 2006-11-29 1:41

In order to compare various sorting algorithms, I am looking for a way to see how much peak memory a function uses. Figuring out the time they take to complete is easy, but this has stumped me. Anyone have a clue?

Name: Anonymous 2006-11-29 4:37

Unfortunately, the C/C++ standard library is crap and does not include a standard function to determine free/used memory (Keep it portable! Maybe some platform doesn't use memory!). You'll need to check for either a non-standard function provided by your compiler (look for mem, core, memory, free, etc.) or a function provided by your OS (careful with that though; prefer private bytes to working set size). Then you measure memory used before running the stuff, and the maximum of the memory used in each iteration.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List