rubenvb
rubenvb

Reputation: 76519

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!

Upvotes: 4

Views: 1770

Answers (3)

Blrfl
Blrfl

Reputation: 7003

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.

Upvotes: 0

Puppy
Puppy

Reputation: 146910

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

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

Upvotes: 0

AndreasT
AndreasT

Reputation: 9801

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.

Upvotes: 1

Related Questions