C++ 如何知道C++中的内存使用情况
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10183528/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to know the memory usage in C++
提问by LoveTW
I have a C++ program running by Visual Studio 2010, how can i monitor the the memory usage of my program? Does there exist simple API, such as i can call clock_t start1
and start1 = clock();
to monitor the time usage of my program. Thanks:)
我有一个由 Visual Studio 2010 运行的 C++ 程序,如何监控程序的内存使用情况?是否存在简单的API,例如我可以调用clock_t start1
并start1 = clock();
监控我的程序的时间使用情况。谢谢:)
采纳答案by NattyBumppo
Memory management is not an easy problem like timing, and it is definitely more complicated to track.
内存管理不是像计时一样简单的问题,跟踪起来肯定更复杂。
I recommend looking at other similar StackOverflow posts to get started:
我建议您查看其他类似的 StackOverflow 帖子以开始使用:
How to analyse program's memory usage in Visual Studio 2010?
如何在 Visual Studio 2010 中分析程序的内存使用情况?
How do you detect/avoid Memory leaks in your (Unmanaged) code?
These should help you solve whatever your specific memory-related problem is, whether it's looking for memory leaks, overwriting the end of an allocated buffer, or simply tracking how much memory you've allocated.
这些应该可以帮助您解决任何与内存相关的特定问题,无论是查找内存泄漏、覆盖已分配缓冲区的末尾,还是只是跟踪已分配的内存量。