The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Devel::MemoryTrace::Light - Print a message when your program grows in memory

VERSION

version .01

SYNOPSIS

  perl -d:MemoryTrace::Light Program

DESCRIPTION

Prints out a message when your program grows in memory containing the package, file, line, and number of bytes (resident set size) your program increased. For example, if your program looked like this:

  #!/usr/bin/perl

  use strict;
  use warnings;

  my @arr;
  $arr[4096] = 'hello';

Then the output will look like:

  >> init, 0 (0) used 8192 bytes
  >> main, ex.pl (9) used 20480 bytes

RUN-TIME CONTROL OF TRACING

If you would like to override the default behavior of printing to STDOUT whenever the program size increases, you may provide your own callback method.

set_callback(\&somefunc)

Causes \&somefunc to be called whenever the debugger detects an increase in memory size. \&somefunc should accept 4 arguments:

  • $pkg

  • $file

  • $line

  • $bytes

restore_callback()

Restores the default callback.

AUTHOR

Matthew Horsfall (alh) - <WolfSage@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Matthew Horsfall.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.