有没有最好的方法来自动化内存泄漏测试?

发布于 2024-08-23 13:02:30 字数 104 浏览 6 评论 0原文

我们正在自动化大多数可以自动化的已知问题(用于回归测试)。然而,我们确实通过第三方软件发现了内存泄漏。但是,我不知道如何自动执行我们发现并修复它们的内存泄漏测试。

有什么建议吗?

We are in a process of automating the most of known issues(for regression testing) that can be automated. However, we do find memory leaks through third party software. However, I do not know the way to automate the memory leak test that we found and fixed them.

Is there any advise on it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

仲春光 2024-08-30 13:02:30

一般来说,最好的方法是只做您认为导致泄漏的事情,并且,好吧,看着内存只增加。

但当然,您需要测试在那段时间“什么都不做”是否也会导致记忆力上升。

因此,以及追踪泄漏(尤其是在第 3 方软件中)通常令人困惑的复杂性质,为其编写自动化测试可能非常困难。

这实际上取决于您的环境。也许可以构建一个始终从头开始的环境(即虚拟机),但这可能是不可能的。

就我个人而言,我有一个单独的但仍然是部分自动化的系统来检测泄漏,并“经常”运行它。如果是第 3 方,则只需在添加新版本的软件时执行此操作。

Generally the best way is to only do the thing that you think causes the leak, and, well, watch the memory only go up.

But of course, you need to test that doing "nothing" over that period of time, doesn't also cause memory to go up.

Because of this, and the generally confusing complicated nature of tracking down leaks (especially in 3rd party software) it can be pretty hard to write an automated test for it.

It depends on your environment, really. Perhaps it is possible to build an environment where you always start from scratch (i.e. a virtual machine) but it may not be possible.

Personally, I'd have a seperate, but still partially-automated, system for detecting the leaks, and run it "every so often". If it's 3rd party, you'll only need to do it when you add a new version of the software.

凝望流年 2024-08-30 13:02:30

当程序长时间运行时,内存泄漏就会变得明显。为长时间运行的测试设置一台测试机器,程序启动一次,然后运行几天,无需重新启动。有一组定义的回归测试,并且一遍又一遍地执行。当内存消耗达到某个阈值时,测试将被视为失败。

示例:对于 Web 应用程序,您启动它,然后在几天内一遍又一遍地启动回归测试(模拟用户输入)。编写这些测试脚本并将其添加到持续集成环境中。

这是与通常的回归测试不同的方法,在通常的回归测试中,您只需为每个测试或测试套件启动一次程序。

Memory leaks become obvious when you run the program for a long time. Setup a test machine for long running tests, where the program is started once and then runs for several days without a restart. Have a defined set of regression tests, which is executed over and over again. When the memory consumption reaches some threshold the tests are considered as a failure.

Example: For a web application, you start it and then fire up regression tests (which simulates user input) over and over again for several days. Script these tests and add it to a continuous integration environment.

This is a different approach than usual regression tests, where you just start the program one time for each tests or test suite.

黯然#的苍凉 2024-08-30 13:02:30

有些工具确实可以轻松检测内存泄漏(例如 valgrind),

您可以做的是模拟程序上的“密集”输入(通过脚本 shell)并解析 valgrind 的结果以查看是否存在任何内存泄漏。您也可以自己集中(并且长时间)使用它。 Valgrind 会在程序结束时告诉您是否有内存泄漏(甚至大约泄漏的位置!)

Some tools really make detecting memory leaks easy (like valgrind)

What you could do is simulate an "intensive" input on your program (via a script shell) and parse the result of valgrind to see if there were any memory leaks. You could also use it yourself intensively (and for a long time). Valgrind will tell you at the program's end if any memory leaked (and even approximately where it leaked !)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文