.\" -*- 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 "Memory::Usage 3" .TH Memory::Usage 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 Memory::Usage \- Tools to determine actual memory usage .SH VERSION .IX Header "VERSION" Version 0.201 .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 2 \& use Memory::Usage; \& my $mu = Memory::Usage\->new(); \& \& # Record amount of memory used by current process \& $mu\->record(\*(Aqstarting work\*(Aq); \& \& # Do the thing you want to measure \& $object\->something_memory_intensive(); \& \& # Record amount in use afterwards \& $mu\->record(\*(Aqafter something_memory_intensive()\*(Aq); \& \& # Spit out a report \& $mu\->dump(); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This module lets you attempt to measure, from your operating system\*(Aqs perspective, how much memory a process is using at any given time. .SH METHODS .IX Header "METHODS" .SS "Class Methods" .IX Subsection "Class Methods" .IP "new ( )" 4 .IX Item "new ( )" Creates a new Memory::Usage object. This object will contain usage state as recorded along the way. .SS "Instance Methods" .IX Subsection "Instance Methods" .ie n .IP "record ( $message [, $pid ])" 4 .el .IP "record ( \f(CW$message\fR [, \f(CW$pid\fR ])" 4 .IX Item "record ( $message [, $pid ])" Record the memory usage at call time, logging it internally with the provided message. Optionally takes a process ID to record memory usage for, defaulting to the current process. .IP "report ( )" 4 .IX Item "report ( )" Generates report on memory usage. .IP "dump ( )" 4 .IX Item "dump ( )" Prints report on memory usage to stderr. .IP "state ( )" 4 .IX Item "state ( )" Return arrayref of internal state. Returned arrayref contains zero or more references to arrays with the following columns (in order). All sizes are in kilobytes. .RS 4 .IP "timestamp (in seconds since epoch)" 4 .IX Item "timestamp (in seconds since epoch)" .PD 0 .IP "message (as passed to \->\fBrecord()\fR)" 4 .IX Item "message (as passed to ->record())" .IP "virtual memory size" 4 .IX Item "virtual memory size" .IP "resident set size" 4 .IX Item "resident set size" .IP "shared memory size" 4 .IX Item "shared memory size" .IP "text (aka code or exe) size" 4 .IX Item "text (aka code or exe) size" .IP "data and stack size" 4 .IX Item "data and stack size" .PD .RE .RS 4 .RE .SH AUTHOR .IX Header "AUTHOR" Dave O\*(AqNeill, \f(CW\*(C`\*(C'\fR .SH BUGS .IX Header "BUGS" Please report any bugs or feature requests to \f(CW\*(C`bug\-memory\-usage at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you\*(Aqll automatically be notified of progress on your bug as I make changes. .SH SUPPORT .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc Memory::Usage .Ve .PP You can also look for information at: .IP \(bu 4 RT: CPAN\*(Aqs request tracker .Sp .IP \(bu 4 Search CPAN .Sp .SH "SEE ALSO" .IX Header "SEE ALSO" .IP \(bu 4 Memchmark .Sp Iteratively run coderefs (similar to Benchmark) and compare their memory usage. Useful for optimizing specific subroutines with large memory usage once you\*(Aqve identified them as memory hogs. Uses same technique for gathering usage information as this module, so accuracy and precision suffer similarly. .IP \(bu 4 Devel::Size .Sp Show the size of Perl variables. Also useful for microoptimzations when you know what you\*(Aqre looking for. Looks at Perl internals, so accuracy is good. .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Copyright 2010 Dave O\*(AqNeill. .PP 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. .PP See http://dev.perl.org/licenses/ for more information.