Leak(3)

πŸ’– Leak(3) β€” the perl one πŸ’–

okay so this is Leak(3), from the User Contributed Perl Documentation girliesss β€” and bestie, this little page is all about hunting down perl objects that refuse to be reclaimed. it's giving detective energy πŸ”βœ¨


🌸 NAME 🌸

Devel::Leak β€” a whole utility for looking for perl objects that are not reclaimed. like, they're just sitting there. living rent free. 😭


✨ SYNOPSIS ✨

use Devel::Leak;
... setup code

my $count = Devel::Leak::NoteSV($handle);

... code that may leak

Devel::Leak::CheckSV($handle);

literally that's the whole vibe: snapshot πŸ“Έ, run your sus code, then check. iconic.


πŸŽ€ DESCRIPTION πŸŽ€

so Devel::Leak has exactly two functions and their names are "NoteSV" and "CheckSV" β€” dynamic duo, no cap πŸ’…

"NoteSV" walks the perl internal table of allocated SVs (scalar values) β€” and yes, that table actually contains arrays and hashes too, the more you know πŸ¦‹ β€” and records their addresses in a table. then it returns a count of these "things" and stores a pointer to the table (which it got from the heap using malloc()) in its argument. so like... it's taking attendance πŸ“‹βœ¨

"CheckSV" gets passed that argument holding the pointer to the table that "NoteSV" made. it re-walks the perl-internals and calls sv_dump() for any "things" that were not there when "NoteSV" was called. then it returns a count of how many "things" are allocated now. iykyk β€” the new ones are your suspects πŸ•΅οΈβ€β™€οΈ


🫢 CAVEATS 🫢

bestie, read this part, fr fr 😭
  • note that you need a perl built with -DDEBUGGING for sv_dump() to print anything at all. but good news: counts are valid in any perl 🌈
  • if new "things" have been created, CheckSV may (also) report additional "things" which are allocated by the sv_dump() code itself. yeah, the tool shows up in its own group chat. lowkey awkward πŸ’€

🌸 HISTORY 🌸

this little utility module used to be part of Tk πŸŽ€ until the variable renaming in perl5.005 made it clear that Tk had no business knowing this much about the perl internals. like ma'am, why do you know that πŸ‘€ periodt.


πŸ‘‘ AUTHOR πŸ‘‘

Nick Ing-Simmons <nick@ni-s.u-net.com>


⭐ and that's the page!! slay πŸ¦‹πŸ’œ

this lil cutie came from perl v5.42.0 and it's dated 2011-12-14 β€” so it's a vintage icon, and honestly she still eats πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from