Front page | perl.perl5.porters |
Postings from July 2019
[perl #134305] Memory Leak in perl 5.28 and 5.30
Thread Previous
From:
James E Keenan via RT
Date:
July 24, 2019 21:41
Subject:
[perl #134305] Memory Leak in perl 5.28 and 5.30
Message ID:
rt-4.0.24-8470-1564004459-1311.134305-15-0@perl.org
On Tue, 23 Jul 2019 17:22:46 GMT, a.shikov@dtel-ix.net wrote:
>
> This is a bug report for perl from a.shikov@dtel-ix.net,
> generated with the help of perlbug 1.41 running under perl 5.28.1.
>
>
> -----------------------------------------------------------------
> [Please describe your issue here]
>
> Hello!
>
> Recently we migrated some Perl scripts from old to another server.
> Both servers - FreeBSD.
> On the old server there were 11.2-RELEASE, Perl 5.24.
> On the new server there are 12.0-RELEASE, Perl 5.28.2.
>
> On a new server we've noticed an intensive memory leak. After
> investigation
> the trouble we've found that memory leak is caused by Sys::Syslog and
> can be
> reproduced by simple script:
>
> ---------------------------------------------------------------------------
> #!/usr/local/bin/perl -w
>
> use strict;
> use Sys::Syslog qw(:standard :macros);
>
> openlog('syslog-demo', 'ndelay', LOG_LOCAL2);
>
> my $c = 0;
>
> my @chars = ("A".."Z", "a".."z", "0".."9", "." , "-", "_" );
>
> while ($c++ <= 10000) {
> my $string = '';
> $string .= $chars[rand @chars] for 1..32;
> for (1..512) {
> syslog(LOG_DEBUG, "DEBUG LOG %d/%d RANDOM STRING: %s",
> $c, $_, $string );
> }
> sleep 1;
> }
> ---------------------------------------------------------------------------
>
> Add the line below to syslog.conf to save log to file:
> local2.* /var/log/yarpd.log
>
> Then start script and check out the log file with tail -f.
>
> Right after script is started 'top' shows that memory utilization
> starts to grow rapidly:
>
> last pid: 44500; load averages: 1.12, 1.19, 1.22 up
> 21+05:23:33 15:21:28
> 105 processes: 2 running, 103 sleeping
> CPU: 43.2% user, 0.0% nice, 7.2% system, 0.4% interrupt, 49.2% idle
> Mem: 427M Active, 189M Inact, 6452K Laundry, 448M Wired, 200M Buf,
> 892M Free
> Swap: 4096M Total, 222M Used, 3874M Free, 5% Inuse
>
> PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU
> COMMAND
> 45209 root 1 22 0 19M 8956K nanslp 0 0:00 1.11%
> perl
> [...]
>
> 45209 root 1 22 0 196M 186M nanslp 1 0:04 4.50%
> perl
> [...]
>
> 45209 root 1 22 0 266M 258M nanslp 0 0:05 4.64%
> perl
> [...]
>
> 45209 root 1 22 0 541M 534M nanslp 0 0:11 2.29%
> perl
>
> Tested on physical machine, on virtual machine - the situation is the
> same on both.
> It just depends on the number of messages per second. 512 was enough
> for VDS to
> trigger the problem, on physical machine I tested it with 9000.
>
> The problem is not with Sys::Syslog module, because with Unix::Syslog
> the problem is the same.
>
> After that I tested this script with three major versions of Perl:
> 5.26.3, 5.28.1, 5.28.2 and 5.30.0
> on my desktop with FreeBSD 12.0-RELEASE.
>
> Only with 5.26.3 the script does not eats memory. The rest three
> versions have this
> problem. It looks like in 5.28 there is a kind of bug causing memory
> leak if there is
> intensive I/O operation invoked, for example, by generating of big
> number of syslog messages.
>
> Any suggestions are kindly appreciated. Thanks!
>
1. I'm a bit confused by this report. Near the top you say, "we've found that memory leak is caused by Sys::Syslog". But later on, you say, "The problem is not with Sys::Syslog module, because with Unix::Syslog the problem is the same." Which is it?
2. Have you tried your diagnostic script on FreeBSD-11 with perl-5.26, 5.28 and 5.30? What results do you get there? (We have to try to distinguish between changes in Perl and changes in FreeBSD.)
Thank you very much.
--
James E Keenan (jkeenan@cpan.org)
---
via perlbug: queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=134305
Thread Previous