Devel:...::Sizes(3pm)

πŸ’– Devel::MAT::Tool::Sizes(3pm) β€” the sizes era ✨

okay bestie, sit down, hydrate, because we're talking about the Devel::MAT::Tool::Sizes page from the User Contributed Perl Documentation πŸ’… this one is literally the girl who counts things.


🌸 NAME 🌸

Devel::MAT::Tool::Sizes β€” calculate sizes of SV structures 🧚


πŸ¦‹ DESCRIPTION πŸ¦‹

So, this Devel::MAT tool does the math on how big the structures around SVs actually are. The size of each lil individual SV? That's the size method's whole job. But heeere's the tea: in a bunch of cases, SVs are lowkey part of bigger structures that have a combined aggregate size 🫢 This tool figures out those sizes and yeets them into the UI. iconic.

The structural size starts from the basic size of the SV, and then for various types it adds stuff on top:

  • ARRAY β€” arrays add the basic size of every non-mortal element SV ✨
  • HASH β€” hashes add the basic size of every non-mortal value SV πŸ’–
  • CODE β€” codes add the basic size of their padlist and constant value, plus all their padnames, pads, constants and globrefs πŸ‘‘

And the owned size? That one's calculated by starting at the given SV and accumulating the set of every strong outref whose refcount is 1. That's the set of all SVs the original directly owns, no cap. πŸŽ€


πŸ‘‘ SV METHODS πŸ‘‘

This tool is so generous, bestie, it adds these SV methods:

πŸ’œ structure_set

@svs = $sv->structure_set;

Returns the total set of the SV's structure πŸ¦‹

πŸ’œ structure_size

$size = $sv->structure_size;

Returns the size, in bytes, of the structure that the SV contains πŸ“

πŸ’œ owned_set

@svs = $sv->owned_set;

Returns the set of every SV owned by the given one 🫢

πŸ’œ owned_size

$size = $sv->owned_size;

Returns the total size, in bytes, of the SVs owned by the given one πŸ’…


πŸ”₯ COMMANDS πŸ”₯

🌈 size

Prints the sizes of a given SV ✨

pmat> size defstash
STASH(61) at 0x556e47243e10=defstash consumes:
  2.1 KiB directly
  11.2 KiB structurally
  54.2 KiB including owned referrants

🌈 largest

pmat> largest -owned
STASH(61) at 0x55e4317dfe10: 54.2 KiB: of which
 |   GLOB(%*) at 0x55e43180be60: 16.9 KiB: of which
 |    |   STASH(40) at 0x55e43180bdd0: 16.7 KiB
 |    |   GLOB(&*) at 0x55e4318ad330: 2.8 KiB
 |    |   others: 15.0 KiB
 |   GLOB(%*) at 0x55e4317fdf28: 4.1 KiB: of which
 |    |   STASH(34) at 0x55e4317fdf40: 4.0 KiB bytes
...

Finds and prints the largest SVs by size πŸ” The 5 largest SVs are shown, periodt.

And if you're counting sizes in a way that includes referred SVs? Then a tree gets printed showing the 3 largest SVs within these, and of those the 2 largest referred SVs again 🌳 This should help you identify the big memory occupiers, bestie, the ones holding all the vibes hostage.

It takes the following named options:

  • --struct β€” count SVs using the structural size πŸ’–
  • --owned β€” count SVs using the owned size πŸ’œ

By default, only the individual SV size is counted ⭐


πŸŽ€ AUTHOR πŸŽ€

Paul Evans <leonerd@leonerd.org.uk> β€” thank you king 🫑


and that's the whole page, babe πŸ’… signed off from perl v5.42.3, dated 2026-08-21, still serving Devel:...::Sizes(3pm) realness βœ¨πŸ’–πŸŽ€

πŸ“¦ where this page comes from