Skip to content

Instantly share code, notes, and snippets.

@hirose31
Created April 4, 2014 07:59
Show Gist options
  • Select an option

  • Save hirose31/9970134 to your computer and use it in GitHub Desktop.

Select an option

Save hirose31/9970134 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
# Time-stamp: <2014-04-04 16:58:12 JST, hirose31>
use strict;
use warnings;
use IO::File;
STDOUT->autoflush(1);
STDERR->autoflush(1);
use Data::Dumper;
BEGIN {
sub p($) {
local $Data::Dumper::Indent = 1;
local $Data::Dumper::Deepcopy = 1;
local $Data::Dumper::Sortkeys = 1;
local $Data::Dumper::Terse = 1;
local $Data::Dumper::Useqq = 1;
local $Data::Dumper::Quotekeys = 0;
my $d = Dumper($_[0]);
$d =~ s/\\x{([0-9a-z]+)}/chr(hex($1))/ge;
print STDERR $d;
}
}
use Time::HiRes qw(sleep);
system(qq{echo "./dump-perl-memusage -p $$" > /tmp/d});
$SIG{CHLD} = sub { warn "got SIGCHLD\n" };
while (1) {
if (my $pid = fork) {
print '.';
# sleep 0.1;
} else {
$SIG{CHLD} = 'DEFAULT';
sleep 0.1;
exit;
}
}
__END__
while true; do bash /tmp/d; rm -f /tmp/dump_memusage.* ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment