简体   繁体   English

如何在执行应用程序时获取已用内存量

[英]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.

相关问题 如何找出使用的内存量 - how to find out the amount of memory used 获取图形内存量 - Get amount of graphics memory malloc分配的内存可以使用多少时间? - The amount of time malloc allocated memory can be used for? 如何获取多维向量使用的memory - How to get the memory used by a multidimensional vector 如何获取Apple / Mac上的可用虚拟内存量? - How to get the amount of free virtual memory on Apple / Mac? 为什么即使释放了内存,使用的内存量也会增加? - Why the amount of used memory increases even after the memory is released? 如何以编程方式获取应用程序的内存使用情况 - How to get memory usage of an application programmatically 如何在C ++中获取OpenGL使用的总内存(以字节为单位)? - How to get total memory in bytes used by OpenGL in C++? 如何获取Windows中特定进程使用的物理内存和cpu? - How to get physical memory and cpu used by particular process in windows? 宏是否有可能扩展为在程序启动时只执行一次的代码,而不管它被使用了多少次? - Is it possible for a macro to expand to code that will be executed exactly once when a program starts, regardless of how many times it's used?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM