Skip Menu |

This queue is for tickets about the SOAP-Lite CPAN distribution.

Report information
The Basics
Id: 37040
Status: resolved
Priority: 0/
Queue: SOAP-Lite

People
Owner: Nobody in particular
Requestors: rekoil [...] semihuman.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.710.07
Fixed in: 0.710.08



Subject: Memory leak when calling WS using wsdl
There appears to be a slow memory leak when using a .wsdl file to make SOAP calls. Sample code attached. The attached script grew from ~11MB at start to ~20MB RES size (VIRT went from 14MB to ~24MB) after running ~40,000 query loops. Confirmed this under both Ubuntu 6.06 LTS (perl 5.8.7) and Debian 4.0 STABLE (perl 5.8.8) with SOAP::Lite 0.71.07 installed from CPAN. Attached code is .pl file, .wsdl, as well as a PHP-based server which runs from the same .wsdl.
Subject: auth_mem_leak_test.pl
#!/usr/bin/perl -w use strict; use SOAP::Lite; #use SOAP::Lite +trace => [qw (debug)]; use Data::Dumper; # .NET compatibility configuration per SOAP::Lite manpage $SOAP::Constants::DO_NOT_USE_CHARSET = 1; my $xmlns = 'http://foo.com/webservices/'; my $endpoint = 'http://localhost/Authentication_test.php'; my $strAccount = 'foo'; my $strReferrer = 'unknown'; my $strSourceURL = 'http://bar.com/test/object.jpg'; my $strClientIP = '1.2.3.4'; my $query_count = 1; while (1) { my $strToken = int(rand(10000)); my $soap = SOAP::Lite->service('file://var/www/Auth.wsdl') #->proxy($endpoint) ->ns('http://foo.com/webservices', 'tns'); $soap->on_fault(\&handle_fault); print "Sending token $strToken: "; my $result = $soap->Authenticate($strAccount, $strToken, $strReferrer, $strSourceURL, $strClientIP); if ($result) { print "Query $query_count: Authentication passed!\n"; } else { print "Query $query_count: Authentication failed.\n"; } $query_count++; } sub handle_fault { my ($soap, $res) = @_; my $err = $soap->transport->status; print "SOAP Transport error: $err\n"; }
Subject: Auth.wsdl
<?xml version="1.0" ?> <definitions name="Authentication" targetNamespace="http://foo.com/webservices" xmlns:typens="http://foo.com/webservices" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <types> <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://foo.com/webservices"> </xsd:schema> </types> <message name="doAuthenticate"> <part name="strAccount" type="xsd:string" /> <part name="strToken" type="xsd:string" /> <part name="strReferrer" type="xsd:string" /> <part name="strSourceURL" type="xsd:string" /> <part name="strClientIP" type="xsd:string" /> </message> <message name="doAuthenticateResponse"> <part name="Result" type="xsd:int" /> </message> <portType name="AuthenticationPort"> <operation name="Authenticate"> <input message="typens:doAuthenticate" /> <output message="typens:doAuthenticateResponse" /> </operation> </portType> <binding name="AuthenticationBinding" type="typens:AuthenticationPort"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> <operation name="Authenticate"> <soap:operation soapAction="http://foo.com/webservices/Authenticate" /> <input> <soap:body use="encoded" namespace="http://foo.com/webservices" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> </input> <output> <soap:body use="encoded" namespace="http://foo.com/webservices" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> </output> </operation> </binding> <service name="AuthenticationService"> <port name="AuthenticationPort" binding="typens:AuthenticationBinding"> <soap:address location="http://localhost/Authentication_test.php" /> </port> </service> </definitions>
Subject: Authentication_test.php
<?php // Version 1.0 // This is a sample PHP to implement an authentication web service // our servers will call your web service to Accept or Reject connections // If code is to provide a starting point for a developer wanting to create their own // authentication rules for their streaming. // // If you modify this script or create a new one make sure you keep your SOAP messages compatible // with the definitions inside Authentication.wsdl // // If you change the WSDL definitions or SOAP structure the client may not understand how to // interact with your code // Create a soap server object based off the standard WSDL provided. $server = new soapserver("Auth.wsdl", array('encoding'=>'UTF-8')); /* function: Authenticate * Purpose: This is the method that will be called during each connection * Use one of the input parameters as a criteria to authenticate the client * * Comments: Keep the duration between entering and exiting this function to a minimum * The client cannot begin streaming until you send back a result * If an extremely long time has lapsed the web service client may also terminate the * connection * * Inputs: * (strings)account The name of the account associated with this request * This could be useful if you have multiple accounts, otherwise is will * always contain the same value. * * (strings)token This is the unique string that was passed into the Player * This can be a alpha numeric and should not be predictable * * (strings)referrer This is the referrer passed to the server, usually this is the url * to the .swf * * (strings)sourceURL This is the full URL being requested from the server * * (strings)ip This is the IP of the client connecting to the server * * Output: * (int)0 Reject Access * (int)1 Accept Access */ function Authenticate($account, $token, $referrer, $sourceurl, $ip) { // A very simple demonstration of how you can accept/reject connection on specific criteria // In this case if the token is an even number we will allow access, if the number is odd we reject if($token % 2 == 0) { $retval = "1"; } else { $retval = "0"; } return $retval; // return ACCEPT(1) or REJECT(0) } // map the SOAP operation to the appropriate PHP function above $server->addFunction("Authenticate"); // This is just some extra code to show what web service function is available if you browse this PHP if ($_SERVER["REQUEST_METHOD"] == "POST") // If this is a post from the web service client then handle soap { header("Content-Type: text/xml"); // The client calling this code expects XML content-type $server->handle(); // process the soap } else // this is probably a browser querying what function is available in this php { echo "This SOAP server can handle following functions:<br> "; $functions = $server->getFunctions(); foreach($functions as $func) { echo $func . "<br>"; } } ?>
From: rekoil [...] semihuman.com
After running overnight (112K queries), here's the ps line: rekoil 29077 100 3.4 38040 35508 pts/2 R+ 00:01 530:23 /usr/bin/perl -w ./auth_mem_leak_test.pl 35MB RES, 38MB VIRT.
According to Devel::Leak, even this simple script leaks 2 scalars: #!/usr/bin/perl -w use Devel::Leak; use SOAP::Lite; my $endpoint = 'http://localhost/Authentication_test.php'; my $table; my $count = Devel::Leak::NoteSV($table); for (1..11) { my $soap = SOAP::Lite->new() ->proxy($endpoint); print "# SV count: ", Devel::Leak::NoteSV($table), "\n"; } Commenting out the ->proxy($endpoint) line helps, but that's obviously a no-go... Martin
Subject: Re: [rt.cpan.org #37040] Memory leak when calling WS using wsdl
Date: Sat, 28 Jun 2008 19:59:12 +0200
To: bug-SOAP-Lite [...] rt.cpan.org
From: Martin Kutter <martin.kutter [...] fen-net.de>
Looks like this is due to two errors (one obvious, the other more subtle) in SOAP::Transport::HTTP. Could you try an updated version available at https://soaplite.svn.sourceforge.net/svnroot/soaplite/branches/0.71/lib/SOAP/Transport/HTTP.pm Thanks, Martin
From: rekoil [...] semihuman.com
On Sat Jun 28 13:59:44 2008, martin.kutter@fen-net.de wrote: Show quoted text
> Looks like this is due to two errors (one obvious, the other more > subtle) in SOAP::Transport::HTTP. Could you try an updated version > available at > >
https://soaplite.svn.sourceforge.net/svnroot/soaplite/branches/0.71/lib/SOAP/Transport/H TTP.pm Show quoted text
> > Thanks, > > Martin >
Doesn't look like that solved it - I ran the test overnight (~2M iterations) and wound up with a 170M binary: ekoil@tino:~$ ps aux | grep auth_mem_leak rekoil 15688 95.4 17.0 176648 174176 pts/1 R+ Jun28 1062:38 /usr/bin/perl -w ./auth_mem_leak_test.pl Will run Devel::Leak against my tests as well.
Subject: Re: [rt.cpan.org #37040] Memory leak when calling WS using wsdl
Date: Mon, 30 Jun 2008 08:51:28 +0200
To: bug-SOAP-Lite [...] rt.cpan.org
From: Martin Kutter <martin.kutter [...] fen-net.de>
Hi Chris, on my box I get a constant memory footprint with the updated HTTP transport backend (at least for the first few thousand requests). Are you sure you're using the patched HTTP.pm? Martin Am Sonntag, den 29.06.2008, 09:38 -0400 schrieb Chris Woodfield via RT: Show quoted text
> Queue: SOAP-Lite > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=37040 > > > On Sat Jun 28 13:59:44 2008, martin.kutter@fen-net.de wrote:
> > Looks like this is due to two errors (one obvious, the other more > > subtle) in SOAP::Transport::HTTP. Could you try an updated version > > available at > > > >
> https://soaplite.svn.sourceforge.net/svnroot/soaplite/branches/0.71/lib/SOAP/Transport/H > TTP.pm
> > > > Thanks, > > > > Martin > >
> > Doesn't look like that solved it - I ran the test overnight (~2M iterations) and wound up with > a 170M binary: > > ekoil@tino:~$ ps aux | grep auth_mem_leak > rekoil 15688 95.4 17.0 176648 174176 pts/1 R+ Jun28 1062:38 /usr/bin/perl -w > ./auth_mem_leak_test.pl > > Will run Devel::Leak against my tests as well. > >