如何测试内存泄漏? [英] How to Test for Memory Leaks?

查看:117
本文介绍了如何测试内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个具有数百种可能的用户操作的应用程序,并考虑如何增强内存泄漏测试.

We have an application with hundreds of possible user actions, and think about how enhancing memory leak testing.

当前,这是它的发生方式:手动测试软件时,如果看来我们的应用程序消耗了太多内存,我们将使用内存工具,查找原因并解决问题.这是一个相当缓慢且效率不高的过程:问题被发现得很晚,并且依赖于一个开发人员的良好意愿.

Currently, here's the way it happens: When manually testing the software, if it appears that our application consumes too much memory, we use a memory tool, find the cause and fix it. It's a rather slow and not efficient process: the problems are discovered late and it relies on the good will of one developer.

我们如何改善呢?

  • 内部检查某些操作(例如关闭文件")是否确实恢复了一些内存并记录下来?
  • 在我们的单元测试中声明内存状态(但似乎这是一个繁琐的任务)?
  • 不定期手动检查吗?
  • 在每次实施新用户故事时都包括该检查吗?

推荐答案

哪种语言?

我会使用Valgrind之类的工具,尝试充分锻炼该程序并查看其报告.

I'd use a tool such as Valgrind, try to fully exercise the program and see what it reports.

这篇关于如何测试内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆