On Aug 18, 2006, at 6:24 AM, Andreas Rieke wrote:

> Hi,
>
> after booting a redhat enterprise linux 3 machine with apache 2.0.58,
> perl 5.8.8 and mod_perl 2.0.2,
> it runs well using about 300 M of 1 G physical RAM.
> However, the remaining RAM decreases day by day, and after 2 or 3
> weeks, the machine crashes because swapping takes too much time.
> However, all processes together take about 250 MBytes according to ps,
> thus I assume that the kernel takes the rest. free tells me in fact
> that
> much swap space is used an nearly no physical RAM is left.
>
> The strange thing is that all the memory is gone even after
> stopping all
> apache processes.
> The only thing which helps is to reboot the machine.



I'm experiencing nearly the same thing now on
FreeBSD 6.0 REL
Apache/2.0.58
mod_perl 2.0.2
Postgres 8.1.3

From what I can tell, this is happening:
bootup: ( pg ) 861 Free
apache start: ( apache , pg , 3x pg clients ) 785 Free
apache stop: ( pg, 3x pg clients ) 840 Free
apache start: ( apache , pg , 3x pg clients ) 774 Free
apache stop: ( pg, 3x pg clients ) 829 Free
apache start: ( apache , pg , 3x pg clients ) 773 Free
apache stop: ( pg, 3x pg clients ) 829 Free

Note: the large drop in free memory is correlated to an equal
increase in Pg's shared memory- so i'm not worried about that. Yet.

pg stop: 833 free

oh, wait. whats's that? i killed all those pg connections and no
shared memory was shared? what the...

ugh... lets check with ipcs?

nope, no shared mem for postgres found. that stuff just disappeared

fine, let's just go on with the test

free memory @ start: 773 ( apache , pg , + clients each )

free memory after 10,000 requests : 697M ( apache , pg , + clients
each )
difference : 76M
no worries! This is attributed to:
mp copy-on-write
postgres slurping memory into shared

but wait...

stop apache (pg): 762M
stop postgres () : 773 free

we now have as much free memory NOT running apache & pg as we did
when we WERE running them. thats just a coincidence that the numbers
are the same.


Note that this is a pretty bad test.

I ***THINK*** that this is all to do with pg's shared memory. I
don't have the facilities, however, to test this using MP+ mysql
( which would rule out Apache / modperl and DBI as being the
culprit ), or another postgres method.


So, in regards to the original poster:

a- I think you're going into swap, because your Postgres config
doesn't have a limit on memory Perhaps your apache too. Check
that. Load a ton of crap into Apache before the fork, and set max-
requests to 500 or so. That should severely limit your memory use.
b- I think only reboots work to reclaim memory, because there seems
to be an oddity with Postgres releasing shared memory.





// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
| FindMeOn.com - The cure for Multiple Web Personality Disorder
| Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
| RoadSound.com - Tools For Bands, Stuff For Fans
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -