[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Fwd: memleak in perl bindings (SVN::Client)

From: Peter Samuelson <peter_at_p12n.org>
Date: Tue, 24 Mar 2009 06:47:42 -0500

Hi,
I got this from a Debian user of the perl bindings in 1.5.1. I haven't
yet tried to reproduce in newer code, but I understand the perl
bindings haven't changed all that much lately.

Is anyone equipped to look into this? Thanks,
Peter

-- Martín Ferrar writes --

SVN::Client leaks so much memory, that it's not usable for any important
project. I'm attaching a test case that shows clearly the problem.

Steps to reproduce:

Save the attached script as "test"

$ svnadmin create /tmp/foo
$ svn import -m FOO test
file:///tmp/foo/test
Adding test

Committed revision 1.
$ perl test
Reusing the SVN object
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
martin 20600 0.0 0.6 21380 6592 pts/7 S+ 19:41 0:00 perl
test
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
martin 20600 42.0 5.2 73560 53528 pts/7 S+ 19:41 0:00 perl
test
NOT reusing the SVN object
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
martin 20600 54.0 0.6 21524 6908 pts/7 S+ 19:41 0:00 perl
test foo
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
martin 20600 94.0 2.2 41856 22608 pts/7 S+ 19:41 0:01 perl
test foo

As you can see, while destroying the SVN object on each step alleviates
the problem, there's still a very noticeable increment in memory usage,
and a serious degradation in performance. If reusing the object, the
memory grows unbounded, today we almost killed alioth when running a
re-scan of the complete pkg-perl repository with the PET tool.

This run was testing the "ls" method. The "cat" method is much worse,
and dependent of the size of the object. Using the script source as
test:

$ perl test
Reusing the SVN object
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
martin 20871 0.0 0.6 21380 6592 pts/7 S+ 19:48 0:00 perl
test
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
martin 20871 44.0 7.1 103520 73204 pts/7 S+ 19:48 0:00 perl
test
NOT reusing the SVN object
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
martin 20871 56.0 0.6 21524 6920 pts/7 S+ 19:48 0:00 perl
test foo
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
martin 20871 95.0 2.0 41960 21448 pts/7 R+ 19:48 0:01 perl
test foo

Using a 100k file:

$ perl test
Reusing the SVN object
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
martin 20922 0.0 0.6 21380 6596 pts/7 S+ 19:49 0:00 perl
test
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
martin 20922 68.0 21.3 266044 218972 pts/7 S+ 19:49 0:01 perl
test
NOT reusing the SVN object
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
martin 20922 75.0 0.6 21524 6920 pts/7 S+ 19:49 0:01 perl
test foo
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
martin 20922 92.5 7.8 106264 80696 pts/7 S+ 19:49 0:03 perl
test foo

[...]

Versions of packages libsvn-perl depends on:
ii libapr1 1.2.12-5 The Apache Portable Runtime Librar
ii libc6 2.7-18 GNU C Library: Shared libraries
ii libsvn1 1.5.1dfsg1-2 Shared libraries used by Subversio
ii perl 5.10.0-19 Larry Wall's Practical Extraction
ii perl-base [perlapi-5.10.0] 5.10.0-19 minimal Perl system

[...]

#!/usr/bin/perl -w

use SVN::Client;

$arg = shift;

if($arg) {
        warn "NOT reusing the SVN object\n";
        open FOO, "> /dev/null";

        my $ctx = new SVN::Client();
        system("ps u $$");
        foreach(1..500) {
                $ctx = new SVN::Client();
                #$ctx->ls('file:///tmp/foo', 'HEAD', 0);
                $ctx->cat (\*FOO, 'file:///tmp/foo/test', 'HEAD');
        }
        system("ps u $$");
} else {
        warn "Reusing the SVN object\n";
        open FOO, "> /dev/null";

        system("ps u $$");
        my $ctx = new SVN::Client();
        foreach(1..500) {
                #$ctx->ls('file:///tmp/foo', 'HEAD', 0);
                $ctx->cat (\*FOO, 'file:///tmp/foo/test', 'HEAD');
        }
        system("ps u $$");

        exec "perl $0 foo";
}
Received on 2009-03-24 12:48:01 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.