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 newMemory::Usageobject. 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 tostderr. 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 π β¨
π LICENSE AND COPYRIGHT π
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
- alpine 3.24: perl-memory-usage-doc 0.201-r4 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms