While investigating a long running perl program for memory leaks I tried to use Test::LeakTrace.
Looking at one of the leaks it reports I can nar开发者_开发百科row down the leaking code to just:
/$?/
So running: perl -MTest::LeakTrace::Script -e'/$?/'
prints:
leaked SCALAR(0x10d3d48) from -e line 1.
Why is this, do I need to worry about it ?
Update: Also tried Devel::LeakTrace::Fast, it's not complaining about the same code.
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.
精彩评论