[nSLUG] bizarre memory leak

Robin Murray nibor.yarrum at gmail.com
Sat Mar 29 11:39:12 ADT 2014

I'm going a little loopy.

I have an apache server running a mod_perl app. I also have mojomojo
installed to store static faq documents using markdown. My big, heady plans
were to treat the mojomojo app as a rest service to pull in the faq content
and inject the snippet into the main website page.

The rest call is very simple:

  # Create a user agent object
  my $ua = LWP::UserAgent->new;
  $ua->agent("xxx/0.1 ");

  # Create a request
  my $wiki = $self->getConfig('wiki');
  my $url =
  $log->debug("About to call $url");
  my $req = HTTP::Request->new(GET => $url);

  # Pass request to the user agent and get a response back
  my $res = $ua->request($req);

  # Check the outcome of the response
  return $res->content if $res->is_success;

All works swimmingly. But here's the catch: if the rest service happens to
be on the local host, I leak gobs of memory, anywhere from 1 to 20 meg per
request, even for a very small snippet of html.

If I put the rest service on a remote host and call it, no leak occurs. If
I put the rest service on the local host, and call that service from a
remote host (ie reverse it), no leak occurs. If both the web site and rest
service are on the local host, swap fills up very quickly.

local web site -> remote rest service -> ok
remote web site -> local rest service -> ok
local web site -> local rest service -> foobar

The only thing I'm changing is the host/port combo used to load the rest
service, nothing else changes at all.

I've even changed the code above to backtick curl so the rest call runs in
it's on process, same thing happens. It's really weird.

I realize this is very little to go on, I haven't even tracked down who is
leaking, it seems like it's spread out. When I restart various parts of
apache/mysql/mojomojo the swap slowly goes back to normal, but no one part
seems to be hogging it all, which is requiring a much more microscopic view.

...but I thought I'd run it by the group to see if anyone else has run into
a similar thing.

Robin Murray
Hatchet Lake,
Nova Scotia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nslug.ns.ca/pipermail/nslug/attachments/20140329/f783fe2e/attachment.html>

More information about the nSLUG mailing list