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

Gisle Aas (gisle@activestate.com)
10 Apr 2001 10:36:34 -0700


"Curt Powell" <curt.powell@sierraridge.com> writes:

> 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?

Seems good enough to me.  I also see memory leaking here.
I'll try to investigate.

Regards,
Gisle


> 
> 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;
> }