Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

www.webdp.net, Event 9 IIS log failed to write entry, wwwxxx jeffs, Catastrophic failure Unexpected method call sequence. 0x8000ffff (-2147418113)., ksh lock a file, [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_DBC failed, sed: -e expression #1, char 1: unterminated address regex, procmail + change subject, w2ksp4.exe download, /proc/kallsyms format

Links

XODOX
Impressum

#1: Memory leak in Perl 5.10 on Solaris 10 with %ENV

Posted on 2008-01-10 15:58:22 by Albert Chin

$ cat leak.pl
sub memused { return `pmap $$|tail -1|awk '{print \$2}'` }

for (my $i=1; 1 or $i<50; $i++) {
do {
local %ENV = %ENV; # <==== this is the leak !
$ENV{HOME} = "/tmp";
};
print " --->> $i iterations --- mem used --->> ", memused()
unless $i % 10000;
}

$ uname -a
SunOS hikaru 5.10 Generic_118833-24 sun4u sparc SUNW,Sun-Fire-V240
$ perl-5.10.0 leak.pl
--->> 10000 iterations --- mem used --->> 59816K
--->> 20000 iterations --- mem used --->> 108968K
--->> 30000 iterations --- mem used --->> 162216K
--->> 40000 iterations --- mem used --->> 215464K
--->> 50000 iterations --- mem used --->> 264616K
...

However, on Solaris 9:
$ uname -a
SunOS hikaru 5.10 Generic_118833-24 sun4u sparc SUNW,Sun-Fire-V240
$ perl-5.10.0 leak.pl
--->> 10000 iterations --- mem used --->> 4504K
--->> 20000 iterations --- mem used --->> 4504K
--->> 30000 iterations --- mem used --->> 4504K
--->> 40000 iterations --- mem used --->> 4504K
...

Perl 5.8.6 behavior on Solaris 10 is fine:
$ perl-5.8.6 leak.pl
--->> 10000 iterations --- mem used --->> 4072K
--->> 20000 iterations --- mem used --->> 4072K
--->> 30000 iterations --- mem used --->> 4072K
--->> 40000 iterations --- mem used --->> 4072K
...

Recompiling Perl 5.10 without -DPERL_USE_SAFE_PUTENV solved the problem.
So, is -DPERL_USE_SAFE_PUTENV known to be unsafe on Solaris 10? Maybe
depending on the Solaris 10 patchlevel?

--
albert chin (china @at@ thewrittenword .dot. com)

Report this message

#2: Re: Memory leak in Perl 5.10 on Solaris 10 with %ENV

Posted on 2008-01-10 17:07:44 by smallpond

On Jan 10, 9:58 am, Albert Chin <ch...@thewrittenword.com> wrote:
> $ cat leak.pl
> sub memused { return `pmap $$|tail -1|awk '{print \$2}'` }
>
> for (my $i=1; 1 or $i<50; $i++) {
> do {
> local %ENV = %ENV; # <==== this is the leak !
> $ENV{HOME} = "/tmp";
> };
> print " --->> $i iterations --- mem used --->> ", memused()
> unless $i % 10000;
>
> }
>
> $ uname -a
> SunOS hikaru 5.10 Generic_118833-24 sun4u sparc SUNW,Sun-Fire-V240
> $ perl-5.10.0 leak.pl
> --->> 10000 iterations --- mem used --->> 59816K
> --->> 20000 iterations --- mem used --->> 108968K
> --->> 30000 iterations --- mem used --->> 162216K
> --->> 40000 iterations --- mem used --->> 215464K
> --->> 50000 iterations --- mem used --->> 264616K
> ...
>
> However, on Solaris 9:
> $ uname -a
> SunOS hikaru 5.10 Generic_118833-24 sun4u sparc SUNW,Sun-Fire-V240
> $ perl-5.10.0 leak.pl
> --->> 10000 iterations --- mem used --->> 4504K
> --->> 20000 iterations --- mem used --->> 4504K
> --->> 30000 iterations --- mem used --->> 4504K
> --->> 40000 iterations --- mem used --->> 4504K
> ...
>
> Perl 5.8.6 behavior on Solaris 10 is fine:
> $ perl-5.8.6 leak.pl
> --->> 10000 iterations --- mem used --->> 4072K
> --->> 20000 iterations --- mem used --->> 4072K
> --->> 30000 iterations --- mem used --->> 4072K
> --->> 40000 iterations --- mem used --->> 4072K
> ...
>
> Recompiling Perl 5.10 without -DPERL_USE_SAFE_PUTENV solved the problem.
> So, is -DPERL_USE_SAFE_PUTENV known to be unsafe on Solaris 10? Maybe
> depending on the Solaris 10 patchlevel?
>
> --
> albert chin (china @at@ thewrittenword .dot. com)

Perl on Solaris 10 has a bug in the handling of ENV. If you try to
make
the ENV larger, you will likely get an out-of-memory error. The fix is
to allocate new memory when ENV is changed - which leaks the old
memory.

http://www.nntp.perl.org/group/perl.perl5.porters/2005/10/ms g105366.html

--S

Report this message

#3: Re: Memory leak in Perl 5.10 on Solaris 10 with %ENV

Posted on 2008-01-10 22:01:48 by Ilya Zakharevich

[A complimentary Cc of this posting was sent to
smallpond
<smallpond@juno.com>], who wrote in article <4d1c20c7-d073-4d29-8545-dc4881e735fd@m34g2000hsf.googlegroups.com>:
> Perl on Solaris 10 has a bug in the handling of ENV. If you try to
> make
> the ENV larger, you will likely get an out-of-memory error. The fix is
> to allocate new memory when ENV is changed - which leaks the old
> memory.
>
> http://www.nntp.perl.org/group/perl.perl5.porters/2005/10/ms g105366.html

If it causes a memory leak, it is not a fix, but a bug. The code in
question keeps a constant ENV memory footprint (it just flips to 0 and
back). IMO, when allocating new memory, Perl should keep the log of
the size allocated.

Hope this helps,
Ilya

Report this message