How to check real memory usage

I uploaded today some changes to production server and after making some tries using added features I get exceeded memory error when I try to display simple “card” with 1 reference. What is weird much complex production cards (it’s kind of ERP system) added before, with many references (300+) was still working.
I increased memory_limit in php.ini from 256M to 512M and it get working.

What is weird for me, peak memory usage showed by debug bar is 18M for mentioned problematic card, and it was unable to run with 256M limit. So how can I check real memory usage? Same question about time of execution, Timer in debug shows much less values than what I can measure with stopwatch or read from browser debug.

My error was about …vendor…query (I don’t have it in logs and can’t reproduce now) and my version is 3.1 but I suppose that differences between 18M and 256M is not version specific.