My mistake - this isn't really fixed. I don't leak memory if I only call 'new' but the problem continues if I call any other function.
I added some 'Devel::Peek' code to my internal package and pulled it out of the Win32::Daemon in order to simplify the problem. Now Im finding that doing a 'Dump' of my 'this' pointer shows some reference counting that I don't understand but certainly looks to be leaking memory. Here is a simple case:
HTTP / SOAP wrapper:
sub http_thread { my $hDaemon = HTTP::Daemon::SSL->new(LocalPort => 8001, SSL_key_file => $curDir . "/certs/server-key.pem", SSL_cert_file => $curDir . "/certs/server-cert.pem" ) || die "Can't start SSH Daemon. $!\n"; my $soap = SOAP::Transport::HTTP::Server -> new ( ) -> dispatch_to(qw(auth)); while (my $hHTTP = $hDaemon->accept) { while (my $request = $hHTTP->get_request) { my $req = $request->{_headers}{soapaction}; $soap->request($request); $soap->handle(); my $response = $soap->response(); $hHTTP->send_response($response); } $hHTTP->close(); undef( $hHTTP ); } }
This gets started via:
$hThread = threads->create( {'void' => 1}, \&http_thread );
The 'auth' class (my SOAP functions):
package auth; use Devel::Peek; sub new { my $pkg = shift; my $self = {}; bless ($self, $pkg); my $cur_time = time; $auth_sessions { $cur_time } = 0; $self->{ SESSIONID } = $cur_time; Dump $self; return $self; } sub temp { my $self = shift; print "\n\n\ntemp\n"; Dump ($self); }
I call the SOAP function as follows:
use SOAP::Lite +autodispatch => proxy => 'https://server:8001/'; my $obj = auth->new(); use Devel::Peek(); print Dump($obj); $obj->temp(); exit;
What I find is that in 'new' the refcnt = 1. When 'new' returns to my calling code refcnt = 4. When I call 'temp' and look at the SOAP pointer refcnt = 5.
So the big questions are:
1 - why is the reference count going so high?
2 - how do I get it back down so that it will GC properly?

EDIT:It appears to be a known problem: Link

In reply to Re^2: Leaking memory from SOAP service by ethrbunny
in thread Leaking memory from SOAP service by ethrbunny

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.