How to get the amount of memory used when running the application

I looked through the GDB documentation but did not find anything that works or shows what I need: the maximum amount of memory that is used by my application.

I use MinGW-w64 (GCC for Windows) if necessary. I would like something programmatically, and not "look in your task manager." Also: my application runs at a time, it does not stop and does not stop anywhere, and I would like to save it that way.

Thanks!

+4
source share
3 answers

You can wrap malloc / free or new / delete: How-to-profile-memory-usage-of-ac-program

This way you can check how much memory (heap) you are using at any time.

+1
source

Windows provides functions to return the amount of memory.

http://msdn.microsoft.com/en-us/library/aa366589(v=VS.85).aspx

0
source

The standard does not specify anything deeper than malloc() and free() , which leaves C libraries free to implement them to work in their target environments. The result is that a debugger such as GDB, which is not tied to a specific environment, will not have an idea of ​​memory allocation.

0
source

Source: https://habr.com/ru/post/1338545/


All Articles