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.开发者_StackOverflow
Thanks!
You could wrap malloc/free or new/delete: How-to-profile-memory-usage-of-a-c-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.
精彩评论