Java Mailing List Archive

http://www.apache-httpd.com/

Home » modperl.perl »

[mp2] Apache2::SizeLimit should be using $s->rss, not $s->size for
Linux::Smaps

Max Kanat-Alexander

2010-02-02

Replies: Find Java Web Hosting

Author LoginPost Reply
 All of my processes kept exiting with a report that they had a 300M
unshared size, which was clearly untrue, even from looking at top. After
some investigation, I discovered that Apache2::SizeLimit was calling
$s->size on the Linux::Smaps object, when instead it should be returning
$s->rss as the process size.

 Attached is a one-line patch to fix the issue.

 Also, if you're interested in proof that this is right, I've attached a
short .cgi file that you can load under mod_perl, with Linux::Smaps
installed, to see process sizes and the return values of all of the
Smaps accessors.

 -Max
--
http://www.everythingsolved.com/
Competent, Friendly Bugzilla and Perl Services. Everything Else, too.
--- Apache2/SizeLimit.pm.old  2010-02-02 15:53:22.000000000 -0600
+++ Apache2/SizeLimit.pm  2010-02-02 15:50:11.000000000 -0600
@@(protected) @@
sub linux_smaps_size_check {

  my $s = Linux::Smaps->new($$)->all;
-   return ($s->size, $s->shared_clean + $s->shared_dirty);
+   return ($s->rss, $s->shared_clean + $s->shared_dirty);
}

# return process size (in KB)
#!/usr/bin/perl -wT
use strict;
use warnings;
use Linux::Smaps;

my $s = Linux::Smaps->new($$)->all;
print "Content-type: text/plain\n\n";
print "SIZE: " . $s->size, "\n";
print "CLEAN: ", $s->shared_clean, " DIRTY: ", $s->shared_dirty, "\n";
print "PRIVATE CLEAN: ", $s->private_clean, " PRIVATE DIRTY: ", $s->private_dirty, "\n";
print "RSS: ", $s->rss, "\n";
©2008 apache-httpd.com - Jax Systems, LLC, U.S.A.