.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "Process 3" .TH Process 3 2025-12-14 "perl v5.42.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME .Vb 1 \& Memory::Process \- Perl class to determine actual memory usage. .Ve .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& 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; .Ve .SH METHODS .IX Header "METHODS" .ie n .SS """new""" .el .SS \f(CWnew\fP .IX Subsection "new" .Vb 1 \& my $m = Memory::Process\->new(%params); .Ve .PP Constructor. .PP Returns instance of object. .ie n .SS """dump""" .el .SS \f(CWdump\fP .IX Subsection "dump" .Vb 1 \& $m\->dump; .Ve .PP Print report to STDERR. .PP Returns return value of \fBprint()\fR. .ie n .SS """record""" .el .SS \f(CWrecord\fP .IX Subsection "record" .Vb 1 \& $m\->record($message, $pid); .Ve .PP Set record. If message not set, use \*(Aq\*(Aq. .PP Returns undef. .ie n .SS """report""" .el .SS \f(CWreport\fP .IX Subsection "report" .Vb 2 \& my @report = $m\->report; \& my $report = $m\->report; .Ve .PP Get report. .PP In scalar context returns string with report. In array context returns array of report lines. First line is title. .ie n .SS """reset""" .el .SS \f(CWreset\fP .IX Subsection "reset" .Vb 1 \& $m\->reset; .Ve .PP Reset records. .PP Returns undef. .ie n .SS """state""" .el .SS \f(CWstate\fP .IX Subsection "state" .Vb 1 \& $m\->state; .Ve .PP Get internal state. .PP Each state item consists from: .PP .Vb 7 \& \- 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) .Ve .PP Returns reference to array with state items. .SH EXAMPLE1 .IX Header "EXAMPLE1" .Vb 2 \& use strict; \& use warnings; \& \& use Memory::Process; \& \& # Object. \& my $m = Memory::Process\->new; \& \& # Example process. \& $m\->record("Before my big method"); \& my $var = (\*(Aqfoo\*(Aq x 100); \& sleep 1; \& $m\->record("After my big method"); \& sleep 1; \& $m\->record("End"); \& \& # Print report. \& print $m\->report."\en"; \& \& # 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 .Ve .SH EXAMPLE2 .IX Header "EXAMPLE2" .Vb 2 \& 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 = (\*(Aqfoo\*(Aq 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: \& # \e [ \& # [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 \& # ] \& # ] .Ve .SH DEPENDENCIES .IX Header "DEPENDENCIES" Memory::Usage, Readonly. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP Memory::Stats 4 .IX Item "Memory::Stats" Memory Usage Consumption of your process .IP Memory::Usage 4 .IX Item "Memory::Usage" Tools to determine actual memory usage .SH REPOSITORY .IX Header "REPOSITORY" .SH AUTHOR .IX Header "AUTHOR" Michal Josef Špaček .PP .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" © 2014\-2023 Michal Josef Špaček .PP BSD 2\-Clause License .SH VERSION .IX Header "VERSION" 0.06