#!/usr/bin/perl
use strict;
use warnings;
use Encode;
sub init {
encode('utf8', 'x' x 100_000_000);
return ();
}
print "starting\n";
sleep 5;
print "initializing\n";
init();
print "initialized\n";
sleep 5;
print "cleaning\n";
undef &Encode::encode;
sleep 5;
####
sub encode($$;$)
{
my ($name, $string, $check) = @_;
# ...
my $octets = $enc->encode($string,$check);
$_[1] = $string if $check and !($check & LEAVE_SRC());
return $octets;
}
##
##
perl -lwe 'my $code = join "", map {
"sub foo$_ { my \$var = q(x) x 1_000_000; }" } 1..1000;
eval $code; die if $@;
for (1..1000) { sleep 1; "foo$_"->() }'
##
##
sub foo1 { my $var = q(x) x 1_000_000; }
sub foo2 { my $var = q(x) x 1_000_000; }
# and so forth...