简体   繁体   English

来自匹配运算符的Perl内存泄漏

[英]Perl memory leak from match operator

While investigating a long running perl program for memory leaks I tried to use Test::LeakTrace . 在调查长时间运行的perl程序以检查内存泄漏时,我尝试使用Test :: LeakTrace

Looking at one of the leaks it reports I can narrow down the leaking code to just: 查看泄漏之一,它报告我可以将泄漏代码缩小为:

/$?/

So running: perl -MTest::LeakTrace::Script -e'/$?/' prints: 这样运行: perl -MTest::LeakTrace::Script -e'/$?/'打印:

leaked SCALAR(0x10d3d48) from -e line 1. 从-e第1行泄漏了SCALAR(0x10d3d48)。

Why is this, do I need to worry about it ? 为什么会这样,我需要担心吗?

Update: Also tried Devel::LeakTrace::Fast , it's not complaining about the same code. 更新:还尝试了Devel :: LeakTrace :: Fast ,它不是在抱怨相同的代码。

Assuming you got a leak. 假设您有泄漏。 Then this: 然后这样:

perl -e'/$?/ for 1..1E9'

should make your process grow in memory 应该使您的过程在内存中增长

 ps -o rss,vsz <PID>

In my case it stays stable all the way. 就我而言,它一直保持稳定。 You should check it for your setup. 您应该检查它的设置。 It could be that leak your module detects is some late destruction. 您的模块检测到的泄漏可能是一些后期破坏。 You could write a note to the module authors to help you figure out its output, you can help them to improve it... 您可以给模块作者写一个注释,以帮助您弄清其输出,可以帮助他们改进它。

BTW another thing confirming "no leak" for me is that on 顺便说一句,对我来说,确认“没有泄漏”的另一件事是

 perl -MTest::LeakTrace::Script -e'/$?/ for 1..1000'

I don't see multiple leaked scalars, just one. 我看不到多个泄漏的标量,只有一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM