Bug report: Memory leak with LWP::UserAgent/HTTP::Request under RH Linux 6.1/7

Curt Powell (curt.powell@sierraridge.com)
Tue, 10 Apr 2001 09:00:48 -0700


Dear sir or madam,

I have encountered a memory leak under RedHat Linux (versions 6.1 and 7),
Perl 5.005 and 5.6.  It occurs with multiple calls to LWP::UserAgent and
HTTP::Request.  Following is a short script that demonstrates the problem.
On RH7 it shows memory deltas of 8k every 10 or so iterations after the
first iteration.  The amount leaked doesn't seem to be related to the size
of the page downloaded.  Is it possible that I am not doing the call
sequence correctly?

Regards,

Curt Powell

#!/usr/bin/perl
#usage: ./memtest <url> e.g. ./memtest http://www.sierraridge.com

sub geturl()
{
	use LWP::UserAgent;
	use HTTP::Request;
	my $URL = shift;
	my $UA = LWP::UserAgent->new();
	my $Request = HTTP::Request->new(GET => $URL);
	my $Response = $UA->request($Request);
	print "Error retrieving $URL\n" if ($Response->is_error());
	return $Response->as_string;
}

sub memused
{
	local *memused_TMP_FILE;
	open(memused_TMP_FILE, "</proc/$$/stat");
	my $a = <memused_TMP_FILE>;
	close memused_TMP_FILE;
	my @b = split(' ', $a);
	return $b[22];
}

$url = shift ARGV;
$lastused = &memused();
for ($i=0; $i<=100; ++$i)
{
	$length = length(&geturl($url));
	$used = &memused;
	$delta = $used - $lastused;
	print "$i: response length: $length memory used: $used memory change:
$delta\n";
	$lastused = $used;
}