Devel:...ngAnSV(3pm)

✨ NAME ✨

Devel::MAT::UserGuide::IdentifyingAnSV β€” figuring out what an SV actually is, bestie πŸ’…

(It's a Perl module doc β€” a 3pm page, if you're keeping track of the vibe check.)


🌸 OVERVIEW 🌸

So like, you're staring at a heap dump file trying to figure out why your memory is doing the absolute most 😭 and you manage to narrow the whole problem down to one single SV at one specific address. Iconic. Love that for you.

But here's the thing β€” the SV is usually just printed with some generic type name, and that raw hex address number? It does not directly tell you which part of the program is actually the one holding onto this SV. It's giving "here's a number, good luck girlie" πŸ’€


πŸ¦‹ IDENTIFYING THE SV πŸ¦‹

To actually find out what the SV is β€” like, what things can even reach it β€” you run the identify command on its address. Simple as that!

pmat> identify 0x6a47708

The output forms a tree of back-references, leading all the way down to known roots of the program: the fixed points in the perl interpreter. Those are the anchor points, the main characters, the ones who never move 🫢


πŸŽ€ When it's short and sweet

Sometimes the tree is tiny and leads you straight to a known root:

pmat> identify 0xfb4770
HASH(0) at 0xfb4770=strtab is:
└─the shared string table HV

In this case the SV is literally a known root directly. A particularly simple result β€” we love a low-effort slay ✨


🌈 When it's a whole saga

Other times it's a longer, less direct path, and maybe it's got multiple branches branching out like a group chat:

pmat> identify 0x72a7140
ARRAY(457025) at 0x72a7140 is:
└─(via RV) value {error} of HASH(3) at 0x490ea40, which is:
  └─(via RV) value {events} of HASH(8)=Mojo::Redis2 at 0x490e0b0, which is:
    └─(via RV) value {ws_redis_master} of HASH(4) at 0x3ebef40, which is:
      β”œβ”€(via RV) the lexical $instances at depth 1 of CODE(PP) at 0x4264c38, which is:
      β”‚ └─the symbol '&Binary::WebSocketAPI::v3::Wrapper::Streamer::shared_redis'
      β”œβ”€(via RV) the lexical $instances at depth 1 of CODE(PP) at 0x42504a0, which is:
      β”‚ └─the symbol '&Binary::WebSocketAPI::v3::Instance::Redis::instances'
      β”œβ”€(via RV) the lexical $instances at depth 1 of CODE(PP) at 0x4257500, which is:
      β”‚ └─the symbol '&Binary::WebSocketAPI::v3::Instance::Redis::redis_pricer'
      β”œβ”€(via RV) the lexical $instances at depth 1 of CODE(PP) at 0x4264920, which is:
      β”‚ └─the symbol '&Binary::WebSocketAPI::Plugins::Helpers::ws_redis_slave'
      └─(via RV) the lexical $instances at depth 1 of CODE(PP) at 0x4263eb8, which is:
        └─the symbol '&Binary::WebSocketAPI::Plugins::Helpers::ws_redis_master'

Okay so here's what's happening: those named symbols count as well-known roots for the purpose of identifying SVs. Our mystery SV has been identified as reachable via a chain of keys, coming from a hash that lives inside a lexical variable named $instances β€” which got captured by five different functions. Five! The audacity 😭


πŸ’€ When it's self-referential (the plot twist)

Sometimes the path from a given SV to the known roots is somehow self-referential, and needs to point back to itself. This gets handled with lettered markers:

pmat> identify 0x55d00c107218
REF() at 0x55d00c107218 is:
└─element [0] of ARRAY(1) at 0x55d00c106f90, which is (*A):
  └─(via RV) value {cycle} of HASH(1) at 0x55d00c1240c8, which is:
    β”œβ”€(via RV) element [0] of ARRAY(1) at 0x55d00c106f90, which is:
    β”‚ └─already found as *A
    └─(via RV) the lexical $loop at depth 1 of CODE() at 0x55d00c107230=main_cv, which is:
      └─the main code

A cycle, a lil loop-de-loop, the SV referencing itself through the chain πŸ™ˆ And in each and every case, the output should at least help you work out what any given SV is β€” by noting what references it, recursively, all the way up to the roots of the interpreter. That's the whole point, no cap πŸ’œ


πŸ‘‘ AUTHOR πŸ‘‘

Paul Evans <leonerd@leonerd.org.uk>


okay that's the whole page, bestie β€” go forth and identify them SVs πŸ§šπŸ’–

This was perl v5.42.3, dated 2026-08-21, part of the User Contributed Perl Documentation for Devel::MAT::UserGuide::IdentifyingAnSV (3pm). Mwah πŸ’…βœ¨

πŸ“¦ where this page comes from