Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you benchmark memory consumption?

I would like to know if there is an efficient way to measure the actual memory consumption of a particular C data structure.

The goal being to make benchmarks based on how the memory usage changes after specific operations on those data structures.

I do not seek a way to count the number of objects in use; I do want to know exactly how big the memory usage of an object put under stress can get.

Is there a standard way to do that, either in C code, or from outside? (Some equivalent to the time (1) utility would be a start).

Obviously, I could track down every single pointer and do a sum of all sizeofs. If this is the only way, please do tell me. I wonder whether there is a simpler way. Or maybe a library to do it for me.

like image 541
Thaddee Tyl Avatar asked Aug 23 '11 07:08

Thaddee Tyl


People also ask

How do you measure memory usage?

Check Computer Memory Usage EasilyTo open up Resource Monitor, press Windows Key + R and type resmon into the search box. Resource Monitor will tell you exactly how much RAM is being used, what is using it, and allow you to sort the list of apps using it by several different categories.

What is memory benchmark?

About memory benchmark A memory benchmark program called memlatency measures memory latency using a simple benchmark code like a meta-code shown in the following figure, and invokes this routine a couple of times for calculating average latency and measurement error(standard deviation).

What is a good memory footprint?

So as a rule of thumb I would recommend staying below 150-200 MB of memory.

What is the command to check memory utilization in Windows?

It's very easy to check both total RAM and available RAM using the command prompt. Open the command prompt, then enter one of the following commands: To obtain total RAM is: systeminfo | findstr /C:"Total Physical Memory" To check available RAM: systeminfo | find "Available Physical Memory"


1 Answers

If you want to monitor the memory usage of the program on a global level you can replace new/delete in C++ or malloc/free in C with your own functions and log the memory usage.

like image 110
Andreas Brinck Avatar answered Sep 27 '22 21:09

Andreas Brinck