Why is this leak?

Why is this leak in Perl?

$ perl -MDevel::LeakTrace::Fast -e 'our @a=(1);our @b=(1)'
leaked SV(0x0x84e053c) from -e line 1

$ perl -v
This is perl, v5.8.0 built for i386-linux-thread-multi
[...]

$ uname -a
Linux ant1 2.4.21-20.ELsmp #1 SMP Wed Aug 18 20:46:40 EDT 2004 i686 i686 i386 GNU/Linux   

Thank!

+3
source share
1 answer

This is not true. Put it in a loop and see for yourself: the process memory does not increase with each iteration of the loop.

for(1 .. 10_000_000)
{
  our @a = (1);
  our @b = (1);
}

All that the “leak message” (probably) tells you that the program exited with outstanding variables. To disable this message, cancel the variables until the end of the program:

perl -MDevel::LeakTrace::Fast -e 'our @a = (1); our @b = (1); undef @a; undef @b;'

FWIW, the same message is printed under perl 5.10.0, so I'm not sure if the perl update is the answer.

As for why the message appears in some cases, but not in others, this is probably a whim of Devel :: LeakTrace :: Fast. Many Perl leak detection modules have "features" (to say the least).

: 100% - , . , .

Devel:: * . : , . . , , . , script. , , , Devel:: (, Devel:: Cycle).

+10

Source: https://habr.com/ru/post/1699671/


All Articles