简体   繁体   中英

How to get the amount of used memory when an application is executed

I have looked through GDB documentation, but haven't found anything that works or shows what I need: the maximum amount of memory that is used by my application.

I'm using MinGW-w64 (GCC for Windows) if that's relevant. I'd like something programmatically, not "look in your task manager". Also: my application executes in one go, it doesn't stop or halt anywhere, and I'd like to keep it that way.

Thanks!

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

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

Windows provides functions to return how much memory is being used.

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

The standard doesn't 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 like GDB that isn't tied to a specific environment will have no insight into memory allocation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM