是否有任何工具可以在我的 Perl 程序中查找内存泄漏? [英] Are there any tools for finding memory leaks in my Perl program?

查看:22
本文介绍了是否有任何工具可以在我的 Perl 程序中查找内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 2003 Server 上使用 ActiveState Perl 5.6,但遇到了一些内存泄漏问题.是否有任何好的工具(甚至可以提供线索的坏工具)我可以用来帮助找到它们.

I am using ActiveState Perl 5.6 on a Windows 2003 Server, and am having some memory leak issues. Are there any good tools (or even bad tools which would give a clue) which I would be able to use to help find them.

推荐答案

所有 perl 程序内存泄漏要么是持有引用的 XS,要么是循环数据结构.Devel::Cycle 是查找循环引用的好工具,如果您知道什么结构的话很可能包含循环.Devel::Peek 可用于查找引用高于预期的对象计数.

All perl program memory leaks will either be an XS holding onto a reference, or a circular data structure. Devel::Cycle is a great tool for finding circular references, if you know what structures are likely to contain the loops. Devel::Peek can be used to find objects with a higher-than-expected reference count.

如果你不知道去哪里找,Devel::LeakTrace::快速可能是一个不错的选择,但您需要一个专为调试而构建的 perl.

If you don't know where else to look, Devel::LeakTrace::Fast could be a good first place, but you'll need a perl built for debugging.

如果您怀疑泄漏发生在 XS-space 内,那就更难了,Valgrind 可能是您最好的选择.Test::Valgrind 可能会帮助您减少需要搜索的代码量,但是这在 Windows 上不起作用,因此您必须将(至少是泄漏部分)移植到 Linux 才能执行此操作.

If you suspect the leak is inside XS-space, it's much harder, and Valgrind will probably be your best bet. Test::Valgrind may help you lower the amount of code you need to search, but this won't work on Windows, so you'd have to port (at least the leaky portion) to Linux in order to do this.

这篇关于是否有任何工具可以在我的 Perl 程序中查找内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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