Process(3)
π NAME π
okay so bestie, this is Process(3) β the manual page for Memory::Process, and its whole vibe is Perl class to determine actual memory usage. no cap, thatβs the main character energy. β¨
πΈ SYNOPSIS πΈ
group chat says use it like this:
use Memory::Process;
my $m = Memory::Process->new(%params);
$m->dump;
$m->record($message, $pid);
my @report = $m->report;
my $report = $m->report;
$m->reset;
$m->state;
π METHODS π
β¨ "new" β¨
my $m = Memory::Process->new(%params);
Constructor. Returns instance of object. π«Ά
β¨ "dump" β¨
$m->dump;
Print report to STDERR. Returns return value of print(). itβs giving printer energy but for your memory report. π
β¨ "record" β¨
$m->record($message, $pid);
Set record. If message not set, use ''. Returns undef. lowkey simple, fr fr.
β¨ "report" β¨
my @report = $m->report;
my $report = $m->report;
Get report. In scalar context returns string with report. In array context returns array of report lines. First line is title. iykyk.
β¨ "reset" β¨
$m->reset;
Reset records. Returns undef. iconic little clean slate. π§
β¨ "state" β¨
$m->state;
Get internal state. Each state item is made from:
- timestamp (in seconds since epoch)
- message (from
record()) - virtual memory size (in kB)
- resident set size (in kB)
- shared memory size (in kB)
- text size (in kB)
- data and stack size (in kB)
Returns reference to array with state items. obsessed. π
π EXAMPLE1 π
okay bestie, hereβs the classic little demo:
use strict;
use warnings;
use Memory::Process;
# Object.
my $m = Memory::Process->new;
# Example process.
$m->record("Before my big method");
my $var = ('foo' x 100);
sleep 1;
$m->record("After my big method");
sleep 1;
$m->record("End");
# Print report.
print $m->report."\n";
# Output like:
# time vsz ( diff) rss ( diff) shared ( diff) code ( diff) data ( diff)
# 1 19120 ( 0) 2464 ( 0) 1824 ( 0) 8 ( 0) 1056 ( 0) After my big method
# 2 19120 ( 0) 2464 ( 0) 1824 ( 0) 8 ( 0) 1056 ( 0) End
π¦ EXAMPLE2 π¦
and this one is giving Data::Printer main character moment:
use strict;
use warnings;
use Data::Printer;
use Memory::Process;
# Object.
my $m = Memory::Process->new;
# Example process.
$m->record("Before my big method");
my $var = ('foo' x 100);
sleep 1;
$m->record("After my big method");
sleep 1;
$m->record("End");
# Print report.
my $state_ar = $m->state;
# Dump out.
p $state_ar;
# Output like:
# \ [
# [0] [
# [0] 1445941214,
# [1] "Before my big method",
# [2] 33712,
# [3] 7956,
# [4] 3876,
# [5] 8,
# [6] 4564
# ],
# [1] [
# [0] 1445941215,
# [1] "After my big method",
# [2] 33712,
# [3] 7956,
# [4] 3876,
# [5] 8,
# [6] 4564
# ],
# [2] [
# [0] 1445941216,
# [1] "End",
# [2] 33712,
# [3] 7956,
# [4] 3876,
# [5] 8,
# [6] 4564
# ]
# ]
π DEPENDENCIES π
youβre gonna need Memory::Usage and Readonly, fr fr. π«Ά
π SEE ALSO π
Memory::Statsβ Memory Usage Consumption of your processMemory::Usageβ Tools to determine actual memory usage
π§ REPOSITORY π§
<https://github.com/michal-josef-spacek/Memory-Process>
π AUTHOR π
Michal Josef Ε paΔek <mailto:skim@cpan.org> β also <http://skim.cz/>. iconic. β¨
πΈ LICENSE AND COPYRIGHT πΈ
Β© 2014-2023 Michal Josef Ε paΔek
BSD 2-Clause License
β VERSION β
0.06 β slay. π
okay thatβs the whole page, bestie π β brought to you by perl v5.42.2, the User Contributed Perl Documentation, dated 2026-02-15, and itβs Process(3) signing off. periodt. π
π¦ where this page comes from
- alpine 3.24: perl-memory-process-doc 0.06-r4 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms