In a recent project I had to measure memory requirements of different algorithms for comparison. However, I had no control over the memory allocation itself (the algorithms were written in matlab), but it seemed that memory would be allocated only when needed and released early when it wasn't needed anymore by the system. So, the idea to measure memory requirements was as follows:
- Get the PID of the running matlab process
- Before start of the algorithm read
/proc/<PID>/status
and parse and record the entry inVmSize
- In the inner loop of each algorithm do the same as in 2) and record the difference between
VmSize
's as the memory consumption of the algorithm
Now my question is: is that a reliable estimator for the memory consumption? Or should I have used a different field (there are quite a few Vm*
fields to choose from, but I found VmSize
to vary most closely to what I expected)? Note, that I don't need 'byte-accurate' measurments but only some 'over-the-thumb' estimates.