1=head1 NAME
2
3Preventive Measures for Performance Enhancement
4
5=head1 Description
6
7This chapter explains what should or should not be done in order to
8keep the performance high
9
10=head1 Memory Leakage
11
12L<Memory leakage in 1.0 docs|docs::1.0::guide::performance/Memory_leakage>.
13
14=head2 Proper Memory Pools Usage
15
16Several mod_perl 2.0 APIs are using Apache memory pools for memory
17management. Mainly because the underlying C API requires that. So
18every time Apache needs to allocate memory it allocates it using the
19pool object that is passed as an argument. Apache doesn't frees
20allocated memory, this happens automatically when a pool ends its
21life.
22
23Different pools have different life lengths. Request pools
24(C<$r-E<gt>pool>) are destroyed at the end of each request. Connection
25pools (C<$c-E<gt>pool>) are destroyed when the connection is
26closed. Server pools C<$s-E<gt>pool>) and the global pools (accessible
27in the server startup phases, like C<PerlOpenLogsHandler> handlers)
28are destroyed only when the server exits.
29
30Therefore always use the pool of the shortest possible life if you
31can. Never use server pools during request, when you can use a request
32pool. For example inside an HTTP handler, don't call:
33
34  my $dir = Apache2::ServerUtil::server_root_relative($s->process->pool, 'conf');
35
36when you should call:
37
38  my $dir = Apache2::ServerUtil::server_root_relative($r->pool, 'conf');
39
40Of course on special occasions, you may want to have something
41allocated off the server pool if you want the allocated memory to
42survive through several subsequent requests or connections. But this
43is normally doesn't apply to the core mod_perl 2.0, but rather for 3rd
44party extensions.
45
46
47=head1 Maintainers
48
49Maintainer is the person(s) you should contact with updates,
50corrections and patches.
51
52=over
53
54=item *
55
56Stas Bekman [http://stason.org/]
57
58=back
59
60=head1 Authors
61
62=over
63
64=item *
65
66Stas Bekman [http://stason.org/]
67
68=back
69
70Only the major authors are listed above. For contributors see the
71Changes file.
72
73=cut
74