Practical mod_perl / HTML Book /



previous page: 5.11.3. Limiting Resources Used by Apache Child Processes
  
page up: HTML Version of the book
  
next page: 5.11.4. Tracking and Terminating Hanging Processes

5.11.3.1. OS-specific notes


Under certain Linux setups, malloc( ) uses mmap( ) instead of brk( ). This is done to conserve virtual memory—that is, when a program malloc( )s a large block of memory, the block is not actually returned to the program until it is initialized. The old-style brk( )system call obeyed resource limits on data segment sizes as set in setrlimit( ). mmap( ) does not.

Apache::Resource's defaults put limits on data size and stack size. Linux's current memory-allocation scheme does not honor these limits, so if we just do:

PerlSetEnv PERL_RLIMIT_DEFAULTS On
PerlModule Apache::Resource
PerlChildInitHandler Apache::Resource

our Apache processes are still free to use as much memory as they like.

However, BSD::Resource also has a limit called RLIMIT_AS (Address Space), which limits the total number of bytes of virtual memory assigned to a process. Fortunately, Linux's memory manager does honor this limit.

Therefore, we can limit memory usage under Linux with Apache::Resource. Simply add a line to httpd.conf:

PerlSetEnv PERL_RLIMIT_AS  67108864

This example sets hard and soft limits of 64 MB of total address space.

Refer to the Apache::Resource and setrlimit(2) manpages for more information.

 

Continue to:

  • prev: 5.11.3. Limiting Resources Used by Apache Child Processes
  • Table of Contents
  • next: 5.11.4. Tracking and Terminating Hanging Processes







TOP
previous page: 5.11.3. Limiting Resources Used by Apache Child Processes
  
page up: HTML Version of the book
  
next page: 5.11.4. Tracking and Terminating Hanging Processes


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