How to Get Memory Usage At Runtime Using C++

Memory usage of current process in C

You can always just open the 'files' in the /proc system as you would a regular file (using the 'self' symlink so you don't have to look up your own pid):

FILE* status = fopen( "/proc/self/status", "r" );

Of course, you now have to parse the file to pick out the information you need.

How can I find how much memory my application is used any any time in c++

if you want measure how much memory is using via above code at runtime u must calculate this:

(# of element in fileList) * sizeof(string) + size of files in fileList

but if you want get all of your process memory usage in windows at runtime you can call GetProcessMemoryInfo API in your program and pass your process handle(GetCurrentProcess() API) to it,sample usage of this API:

see complete response to your question via this link:

How to determine CPU and memory consumption from inside a process?

Related Topics

Leave a reply