Может переменная в цикле которая с utf8 Должна называться $text_ru а не $text_en как у вас закоментировано.
чт, 14 мар. 2019 г. в 14:46, Виктор Меркушов via Moscow-pm <[email protected] >: > Добрый день. > > Почему тут память течёт? Кто-нибудь встречался с таким? > > ==================== code ====================================== > > use utf8; > use strict; > use warnings; > > use Memory::Usage; > use Test::More; > > my $text_ru = "Привет МИР!"; > my $text_en = "Hello World!"; > > subtest "test1" => sub { > my $mu = Memory::Usage->new(); > $mu->record('BEGIN'); > > my $counter = 0; > for ( 1..1_000_000 ) { > # $text_en =~ m/Hello\sWorld/ && $counter++; > $text_en =~ m/Привет\sМИР/ && $counter++; > } > > $mu->record('END'); > > print $mu->report(), $/; > > my $mu_state = $mu->state(); > cmp_ok $mu_state->[-1]->[-1] - $mu_state->[0]->[-1], '<=', 10, > "No more than 10 KB of memory was used for the data."; > > # cmp_ok $counter, '==', 1_000_000, "All matched"; > cmp_ok $counter, '==', 0, "There are no matches"; > }; > > done_testing; > exit(0); > > > ======================= result v5.26.1 Ubuntu 18.04.2 LTS =============== > > $ perl -v > > This is perl 5, version 26, subversion 1 (v5.26.1) built for > x86_64-linux-gnu-thread-multi > > # Subtest: test1 > time vsz ( diff) rss ( diff) shared ( diff) code ( diff) > data ( diff) > 0 32480 ( 32480) 9904 ( 9904) 4544 ( 4544) 2016 ( 2016) > 5868 ( 5868) BEGIN > 0 134780 ( 102300) 112336 ( 102432) 4544 ( 0) 2016 ( > 0) 108168 ( 102300) END > > not ok 1 - No more than 10 KB of memory was used for the data. > # Failed test 'No more than 10 KB of memory was used for the data.' > # at ./memory_leak.t line 28. > # '102300' > # <= > # '10' > ok 2 - There are no matches > > ======================= result v5.12.4 Ubuntu 12.04.5 LTS =============== > > $ perl -v > > This is perl 5, version 12, subversion 4 (v5.12.4) built for x86_64-linux > > # Subtest: test1 > time vsz ( diff) rss ( diff) shared ( diff) code ( diff) > data ( diff) > 0 28084 ( 28084) 7196 ( 7196) 1912 ( 1912) 1248 ( 1248) > 5664 ( 5664) BEGIN > 1 28084 ( 0) 7196 ( 0) 1912 ( 0) 1248 ( 0) > 5664 ( 0) END > > ok 1 - No more than 10 KB of memory was used for the data. > ok 2 - There are no matches > 1..2 > > > -- > Moscow.pm mailing list > [email protected] | http://moscow.pm.org > -- Best regards, Artem V. Zhuravlev
-- Moscow.pm mailing list [email protected] | http://moscow.pm.org
