Inline-Python
view release on metacpan or search on metacpan
t/35dictunicodememleak.t view on Meta::CPAN
my $pt = Proc::ProcessTable->new;
my %info = map { $_->pid => $_ } @{ $pt->table };
my $rss = $info{ $$ }->rss;
if ($^O eq 'darwin') {
# RSS is reported in kilobytes instead of bytes on OS X
$rss *= 1024;
}
return $rss;
}
my $iterations = 3_000_000;
my $rss_before_iterations = get_rss_memory();
# print STDERR "RSS before python_dict_with_unicode_key(): $rss_before_iterations\n";
my $dict;
for (my $x = 0; $x < $iterations; ++$x) {
$dict = python_dict_with_unicode_key();
}
my $rss_after_iterations = get_rss_memory();
# print STDERR "RSS after python_dict_with_unicode_key(): $rss_after_iterations\n";
ok( $rss_after_iterations - $rss_before_iterations < 100 * 1024 * 1024, "RSS takes up less than 100 MB" );
Test::Deep::cmp_deeply( $dict, { 'abcdefghijklmno' => 1, 'pqrstuvwxyz' => 2 } );
( run in 0.525 second using v1.01-cache-2.11-cpan-5511b514fd6 )