develooper Front page | perl.libwww | Postings from April 2001

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

Thread Next
From:
Curt Powell
Date:
April 10, 2001 09:01
Subject:
Bug report: Memory leak with LWP::UserAgent/HTTP::Request under RH Linux 6.1/7
Message ID:
LPBBICBICFBDGHPLFHFMAEDBDEAA.curt.powell@sierraridge.com
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;
}



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About