Memory::Usage(3)

πŸ’– Memory::Usage πŸ’–

okay bestie, so like β€” welcome to the Memory::Usage(3) page, which lives in the User Contributed Perl Documentation section of the manual (iykyk 🫢). This is the whole vibe check on the module, let's get into it ✨


🌸 NAME 🌸

Memory::Usage β€” literally the tools you need to figure out actual memory usage πŸ’…


⭐ VERSION ⭐

Version 0.201, bestie. that's the one. πŸŽ€


✨ SYNOPSIS ✨

here's the whole flow, no cap:

use Memory::Usage;
my $mu = Memory::Usage->new();

# Record amount of memory used by current process
$mu->record('starting work');

# Do the thing you want to measure
$object->something_memory_intensive();

# Record amount in use afterwards
$mu->record('after something_memory_intensive()');

# Spit out a report
$mu->dump();

like, that's it. you snapshot, you do the chaos, you snapshot again, you dump. so clean 🧚


πŸ¦‹ DESCRIPTION πŸ¦‹

This module lets you attempt to measure β€” from your operating system's actual perspective, not from inside Perl's little dream world β€” how much memory a process is using at any given time. it's giving "outside observer energy" πŸ‘‘

note the word attempt bestie, the module is being honest with us. πŸ™ˆ

πŸ”₯ METHODS πŸ”₯

🌈 Class Methods

  • new ( ) β€” makes you a brand new Memory::Usage object. this object is gonna hold all the usage state as it gets recorded along the way. main character object fr πŸ’œ

πŸ“ Instance Methods

  • record ( $message [, $pid ] ) β€” records the memory usage right at the moment you call it, and logs it internally with whatever message you handed over. optionally you can pass a process ID to record memory usage for β€” and if you don't, it just defaults to the current process, nbd 🫢
  • report ( ) β€” generates you a report on memory usage. pretty, printable, iconic ✨
  • dump ( ) β€” prints that report on memory usage to stderr. yes, stderr, that's the whole point, she's not subtle πŸ’€
  • state ( ) β€” returns an arrayref of the internal state. that returned arrayref holds zero or more references to arrays, and each one has the following columns (in order). all sizes are in kilobytes, don't forget that part bestie πŸŽ€
    • timestamp (in seconds since epoch)
    • message (as passed to ->record())
    • virtual memory size
    • resident set size
    • shared memory size
    • text (aka code or exe) size
    • data and stack size

πŸ‘‘ AUTHOR πŸ‘‘

Dave O'Neill, <dmo at dmo.ca> β€” shoutout to the icon who made this πŸ’–


πŸ’€ BUGS πŸ’€

got bugs? feature requests? please report them to bug-memory-usage at rt.cpan.org, or slide in through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Memory-Usage>. he'll get notified, and then you'll automatically get notified of progress on your bug as he makes changes. so like, you're in the loop fr fr πŸ””


🧚 SUPPORT 🧚

you can find the documentation for this module with the perldoc command:

perldoc Memory::Usage

you can also go looking for info at these spots:

  • RT: CPAN's request tracker

<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Memory-Usage>

  • Search CPAN

<http://search.cpan.org/dist/Memory-Usage/>


🌸 SEE ALSO 🌸

  • Memchmark β€” iteratively runs coderefs (similar to Benchmark) and compares their memory usage. super useful for optimizing specific subroutines with big memory usage, once you've already identified them as the memory hogs πŸ‘€. it uses the same technique for gathering usage information as this module does, so the accuracy and precision suffer in a similarly tragic way 😭
  • Devel::Size β€” shows you the size of Perl variables. also handy for microoptimizations when you actually know what you're looking for. it looks at Perl internals, so the accuracy is good πŸ’…βœ¨

Copyright 2010 Dave O'Neill.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See <http://dev.perl.org/licenses/> for more information.


and that's the whole page bestie πŸŽ€ mwah πŸ’‹ β€” this lil doc came to you from perl v5.42.2, dated 2026-02-15, and it's literally the Memory::Usage(3) manpage. slay πŸ’…βœ¨

πŸ“¦ where this page comes from