[英]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. 我查看了GDB文档,但没有发现任何有效或显示我需要的东西:我的应用程序使用的最大内存量。
I'm using MinGW-w64 (GCC for Windows) if that's relevant. 我正在使用MinGW-w64(适用于Windows的GCC),如果这是相关的。 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 你可以包装malloc / free或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. Windows提供了返回正在使用的内存量的函数。
http://msdn.microsoft.com/en-us/library/aa366589(v=VS.85).aspx 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. 该标准没有指定比
malloc()
和free()
更深的东西,这使得C库可以自由地实现它们在目标环境中工作。 The result is that a debugger like GDB that isn't tied to a specific environment will have no insight into memory allocation. 结果是像GDB这样没有绑定到特定环境的调试器将无法深入了解内存分配。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.