is three a way to mesure the amount of memory required during the execution of a C++ program , I am using visual studio 2008.


Do you know how much memory will be allocated during run time?

For example, if you are resizing an array dynamically, based on packet input, the array could be a size much larger than it was at the time the program started.

If you are not using any dynamic memory, then it is technically possible to compute the size required to load your program.

Might I ask why the specific amount of memory is a concern for you?

Thank you for your reply, Ok I am doing a research for my Master thesis, I need to measure the amount of memory required for comparison issues.

I do use dynamic allocation, and its not possible to predict the size of memory used because the algorithm that I use is very complicated


If you're curious about your memory info during runtime, you may want to look at this family of functions:

It is part of the windows API.

It accepts a process handle as a parameter, so with the correct access flags you could read the memory of the other process and do real time comparisons. You could also simply use CreateRemoteThreadEx(), shared memory segments, or message loops. It really depends on what you're trying to do.

Other than during execution, you said yourself you have no idea how much would be dynamically allocated, so it likely is not possible to know before run time. If the algorithm is purely internal mathematics, it may have a maximum value anyway, in which case you would simply use the size of the object you are allocating, plus overhead, and multiply by the maximum size of the array to get a reasonable estimate of the total memory in bytes that will be added to the heap.