Process(3)

πŸ“¦
version 0.06 Β· 2 versions
, in alpine 3.24

πŸ’– 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 process
  • Memory::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. ✨

© 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