.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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 .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Memory::Usage 3pm" .TH Memory::Usage 3pm "2018-10-29" "perl v5.26.2" "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's 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 \s-1ID\s0 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 \->\fIrecord()\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" .RE .RS 4 .RE .PD .SH "AUTHOR" .IX Header "AUTHOR" Dave O'Neill, \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'll 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 \&\s-1RT: CPAN\s0's request tracker .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .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've 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're looking for. Looks at Perl internals, so accuracy is good. .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Copyright 2010 Dave O'Neill. .PP This program is free software; you can redistribute it and/or modify it under the terms of either: the \s-1GNU\s0 General Public License as published by the Free Software Foundation; or the Artistic License. .PP See http://dev.perl.org/licenses/ for more information.