Hello,
I've got a bit of a strange problem that I'm having trouble nailing down.
At first glance, it appears the $m->print makes memory disappear. This is
actually a subset of a larger problem with leaky memory that I'm trying to
fix. This is the smallest reproducible problem of the lot.
I have this component named "argh.html". $contents as retrieved from the
database is always about 900KB every time.
---snip---
<%init>
$dbh = DBI->connect('DBI:Pg:', 'db_name', 'db_password',
{ RaiseError => 1 } );
my $id = int rand(124); # just some random ID
my ($contents) = $dbh->selectrow_array('
SELECT blob FROM blobs WHERE id = ?',
undef, $id);
$m->clear_buffer;
$r->err_headers_out->{'Content-Disposition'} = 'filename="foo"';
$r->err_headers_out->{'Content-Length'} = length $contents;
$r->err_headers_out->{'Cache-Control'} = 'max-age=3600,
must-revalidate';
$r->content_type('application/octet-stream');
$m->print($contents);
$m->abort;
</%init>
<%flags>
inherit => undef
</%flags>
---snip---
Now if I run Apache in debug mode (httpd -X) and do this in a console:
while [ 1 ]; do wget http://mydomain.com/argh.html -O /dev/null; done
While doing this in another console:
while [ 1 ]; do free; ps u -C apache2; sleep 3; done
Then the following happens over the next several minutes that follow. Watch
the VSZ and RSS numbers for the apache2 process.
total used free shared buffers cached
Mem: 516856 303704 213152 0 32900 167156
-/+ buffers/cache: 103648 413208
Swap: 979924 4840 975084
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
www-data 15583 7.4 6.3 313200 32668 pts/1 Sl+ 18:26 0:04
/usr/sbin/apache2 -X
www-data 15586 0.0 3.4 28332 17932 pts/1 S+ 18:26 0:00
/usr/sbin/apache2 -X
[About 15 seconds pass]
total used free shared buffers cached
Mem: 516856 304960 211896 0 32964 167160
-/+ buffers/cache: 104836 412020
Swap: 979924 4840 975084
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
www-data 15583 13.9 6.4 464104 33584 pts/1 Sl+ 18:26 0:09
/usr/sbin/apache2 -X
www-data 15586 0.0 3.4 28332 17932 pts/1 S+ 18:26 0:00
/usr/sbin/apache2 -X
[A couple of minutes pass]
total used free shared buffers cached
Mem: 516856 315060 201796 0 33832 167244
-/+ buffers/cache: 113984 402872
Swap: 979924 4840 975084
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
www-data 15583 35.8 7.8 3120156 40412 pts/1 Sl+ 18:26 1:42
/usr/sbin/apace2 -X
www-data 15586 0.0 3.4 28332 17932 pts/1 S+ 18:26 0:00
/usr/sbin/apache2 -X
Finally Apache crashes, spitting this into error.log:
Out of memory!
Callback called exit.
The interesting bit here is that if I comment out "$m->print($contents);" in
the above component, the problem completely stops. The while loops above
can run indefinitely and VSZ doesn't keep increasing.
So there are two questions here: (1) Why does VSZ for the process keep
increasing, and why does Apache crash with "Out of memory!", when the output
of free shows at all times that there is around 400MB of free physical
memory and even more free swap? (2) What's up with $m->print?
HTML::Mason::ApacheHandler and Apache::DBI are loaded in httpd.conf via
PerlModule. This is happening under Debian etch with the following versions
of relevant packages:
~># dpkg -l | egrep "(apache|mod_perl|mason)" | cut -b-60
ii apache2 2.2.3-4+etch1
ii apache2-mpm-worker 2.2.3-4+etch1
ii apache2-utils 2.2.3-4+etch1
ii apache2.2-common 2.2.3-4+etch1
ii libapache-dbi-perl 1.04-0.1
ii libapache2-mod-perl2 2.0.2-2.4
ii libhtml-mason-perl 1.35-3
--
Troy
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users