Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: What does Test::LeakTrace do?

by choroba (Cardinal)
on Jan 20, 2018 at 22:49 UTC ( [id://1207600]=note: print w/replies, xml ) Need Help??


in reply to What does Test::LeakTrace do?

You can get more information with the -verbose option:
leaktrace{ require './AlmostEmpty.pm'; } -verbose;

And it shows:

leaked SCALAR(0xa6a8a0) from ./3.pl line 7. 6:leaktrace { 7: require './AlmostEmpty.pm' 8:} -verbose; SV = PV(0xa4ac20) at 0xa6a8a0 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0xebe6e0 "./AlmostEmpty.pm"\0 CUR = 16 LEN = 24

So, the leaked scalar contains the required file name. Why is that? Let's read the documentation:

These SVs include global variables and internal caches. For example, if you call a method in a tracing block, perl might prepare a cache for the method. Thus, to trace true leaks, no_leaks_ok() and leaks_cmp_ok() executes a block more than once.

And indeed, running no_leaks_ok shows:

ok 1 - leaks 0 <= 0

So, it's probably some kind of a global variable. And indeed, compare the output with the one from

use Devel::Peek; Dump $INC{'./AlmostEmpty.pm'};

It shows the same scalar. So, it's just the entry in the %INC hash that prevents Perl from including the file once more if you require it again.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: What does Test::LeakTrace do?
by Anonymous Monk on Jan 21, 2018 at 01:45 UTC
    Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1207600]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (2)
As of 2024-04-19 22:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found