Practical mod_perl / HTML Book /



previous page: 14.1.1.1. Potential drawbacks of memory-sharing restrictions
  
page up: HTML Version of the book
  
next page: 14.1.3. Defining the Maximum Unshared Memory Size Threshold

14.1.2. Defining the Maximum Memory Size Threshold


No less important than maximizing shared memory is restricting the absolute size of the processes. If the processes grow after each request, and if nothing restricts them from growing, you can easily run out of memory.

Again you can set the MaxRequestsPerChild directive to kill the processes after a few requests have been served. But as we explained in the previous section, this solution is not as good as one that monitors the process size and kills it only when some limit is reached.

If you have Apache::GTopLimit (described in the previous section), you can limit a process's memory usage by setting the $Apache::GTopLimit::MAX_PROCESS_SIZE directive. For example, if you want processes to be killed when they reach 10 MB, you should put the following in your startup.pl file:

$Apache::GTopLimit::MAX_PROCESS_SIZE = 10240;

Just as when limiting shared memory, you can set a limit for the current process using the set_max_size( ) method in your code:

use Apache::GTopLimit;
Apache::GTopLimit->set_max_size(10000);

For Apache::SizeLimit, the equivalents are:

use Apache::SizeLimit;
$Apache::SizeLimit::MAX_PROCESS_SIZE = 10240;

and:

use Apache::SizeLimit;
Apache::SizeLimit->setmax(10240);

 

Continue to:

  • prev: 14.1.1.1. Potential drawbacks of memory-sharing restrictions
  • Table of Contents
  • next: 14.1.3. Defining the Maximum Unshared Memory Size Threshold







TOP
previous page: 14.1.1.1. Potential drawbacks of memory-sharing restrictions
  
page up: HTML Version of the book
  
next page: 14.1.3. Defining the Maximum Unshared Memory Size Threshold


Menu

  • HTML Book
  • PDF Book
  • Download Code
  • Table of Contents
  • Errata
  • mod_perl2 User's Guide
  • Sitemap

Search


Add to Google




Creative Commons License


Written by
Eric Cholet (Logilune) and
Stas Bekman (StasoSphere & Free Books).


[ Privacy Policy | Terms of Use | About Us | Search ]

© 2007 StasoSphere.com