Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP scripts causing (big!) memory leaks??

Maurice
Guest
 
Posts: n/a
#1: Jul 17 '05
Hi there,

I'm experiencing big memory problems on my webserver. First on an old
RedHat 7.2 system, now on an other fresh installed Suse 8.2 system:

Linux version 2.4.20-4GB (root@Pentium.suse.de) (gcc version 3.3
20030226 (prerelease) (SuSE Linux)) #1 Wed Aug 6 18:26:21 UTC 2003
Apache 1.3.27-41
PHP 4.3.1-52
MySQL 3.23.55-20

Problem is that the system is running out of memory after a while due
to memory leaks, then it starts (almost randomly) killing processes:

dmesg:
__alloc_pages: 0-order allocation failed (gfp=0xf0/0)
__alloc_pages: 0-order allocation failed (gfp=0x1d2/0)
VM: killing process httpd

The memory leak is in the httpd process (thus in Apache, PHP or my
scripts). It grows (within hours) to several hundreds (!) of MB. To
limit the impact of the leaks I changed /etc/httpd/httpd.conf:
MaxRequestsPerChild 10000

This gave the system some breath: after this change the httpd
processes only take a maximum of 12 MB (scripts may take 8 MB as
configured in /etc/php.ini, the rest is probably taken by Apache).

Does anyone of you guys know of existing memory leaks in the above
Apache and PHP packages? It is possible that I have memory leaks in my
script, but I don't understand why they are causing problems now
(after running for over a year without problems).

What are the common pitfalls in PHP scripts that can cause such big
memory leaks?

Randell D.
Guest
 
Posts: n/a
#2: Jul 17 '05

re: PHP scripts causing (big!) memory leaks??



"Maurice" <spam@debijl.net> wrote in message
news:2b4a26d0.0309152253.18fa012a@posting.google.c om...[color=blue]
> Hi there,
>
> I'm experiencing big memory problems on my webserver. First on an old
> RedHat 7.2 system, now on an other fresh installed Suse 8.2 system:
>
> Linux version 2.4.20-4GB (root@Pentium.suse.de) (gcc version 3.3
> 20030226 (prerelease) (SuSE Linux)) #1 Wed Aug 6 18:26:21 UTC 2003
> Apache 1.3.27-41
> PHP 4.3.1-52
> MySQL 3.23.55-20
>
> Problem is that the system is running out of memory after a while due
> to memory leaks, then it starts (almost randomly) killing processes:
>
> dmesg:
> __alloc_pages: 0-order allocation failed (gfp=0xf0/0)
> __alloc_pages: 0-order allocation failed (gfp=0x1d2/0)
> VM: killing process httpd
>
> The memory leak is in the httpd process (thus in Apache, PHP or my
> scripts). It grows (within hours) to several hundreds (!) of MB. To
> limit the impact of the leaks I changed /etc/httpd/httpd.conf:
> MaxRequestsPerChild 10000
>
> This gave the system some breath: after this change the httpd
> processes only take a maximum of 12 MB (scripts may take 8 MB as
> configured in /etc/php.ini, the rest is probably taken by Apache).
>
> Does anyone of you guys know of existing memory leaks in the above
> Apache and PHP packages? It is possible that I have memory leaks in my
> script, but I don't understand why they are causing problems now
> (after running for over a year without problems).
>
> What are the common pitfalls in PHP scripts that can cause such big
> memory leaks?[/color]

I haven't a clue - and don't think anybody else will without examining the
functions called in your script... however I was wondering why you're using
older versions of Apache and PHP? Upgrading to Apache 1.3.28 and PHP 4.3.3
could help plug whatever leaks you're experiencing (and make your system
more secure).


Jon
Guest
 
Posts: n/a
#3: Jul 17 '05

re: PHP scripts causing (big!) memory leaks??


Most likely it's your scripts. Are you doing large database operations,
etc?


"Maurice" <spam@debijl.net> wrote in message
news:2b4a26d0.0309152253.18fa012a@posting.google.c om...[color=blue]
> Hi there,
>
> I'm experiencing big memory problems on my webserver. First on an old
> RedHat 7.2 system, now on an other fresh installed Suse 8.2 system:
>
> Linux version 2.4.20-4GB (root@Pentium.suse.de) (gcc version 3.3
> 20030226 (prerelease) (SuSE Linux)) #1 Wed Aug 6 18:26:21 UTC 2003
> Apache 1.3.27-41
> PHP 4.3.1-52
> MySQL 3.23.55-20
>
> Problem is that the system is running out of memory after a while due
> to memory leaks, then it starts (almost randomly) killing processes:
>
> dmesg:
> __alloc_pages: 0-order allocation failed (gfp=0xf0/0)
> __alloc_pages: 0-order allocation failed (gfp=0x1d2/0)
> VM: killing process httpd
>
> The memory leak is in the httpd process (thus in Apache, PHP or my
> scripts). It grows (within hours) to several hundreds (!) of MB. To
> limit the impact of the leaks I changed /etc/httpd/httpd.conf:
> MaxRequestsPerChild 10000
>
> This gave the system some breath: after this change the httpd
> processes only take a maximum of 12 MB (scripts may take 8 MB as
> configured in /etc/php.ini, the rest is probably taken by Apache).
>
> Does anyone of you guys know of existing memory leaks in the above
> Apache and PHP packages? It is possible that I have memory leaks in my
> script, but I don't understand why they are causing problems now
> (after running for over a year without problems).
>
> What are the common pitfalls in PHP scripts that can cause such big
> memory leaks?[/color]


Jon Kraft
Guest
 
Posts: n/a
#4: Jul 17 '05

re: PHP scripts causing (big!) memory leaks??


Maurice <spam@debijl.net> wrote:
[color=blue]
> I'm experiencing big memory problems on my webserver. First on an old
> RedHat 7.2 system, now on an other fresh installed Suse 8.2 system:
>[/color]
[snip][color=blue]
> The memory leak is in the httpd process (thus in Apache, PHP or my
> scripts). It grows (within hours) to several hundreds (!) of MB. To
> limit the impact of the leaks I changed /etc/httpd/httpd.conf:
> MaxRequestsPerChild 10000[/color]
[snip][color=blue]
>
> What are the common pitfalls in PHP scripts that can cause such big
> memory leaks?[/color]

Hi Maurice,

One common cause is the use of mysql_pconnect() - the implementation of
persistent db connections in PHP is not very stable.
Check your PHP scripts and change to mysql_connect().

HTH;
JOn

gortonc
Guest
 
Posts: n/a
#5: Jul 17 '05

re: PHP scripts causing (big!) memory leaks??



"Maurice" <spam@debijl.net> wrote in message
news:2b4a26d0.0309152253.18fa012a@posting.google.c om...[color=blue]
> Hi there,
>
> I'm experiencing big memory problems on my webserver. First on an old
> RedHat 7.2 system, now on an other fresh installed Suse 8.2 system:
>
> Linux version 2.4.20-4GB (root@Pentium.suse.de) (gcc version 3.3
> 20030226 (prerelease) (SuSE Linux)) #1 Wed Aug 6 18:26:21 UTC 2003
> Apache 1.3.27-41
> PHP 4.3.1-52
> MySQL 3.23.55-20
>
> Problem is that the system is running out of memory after a while due
> to memory leaks, then it starts (almost randomly) killing processes:
>
> dmesg:
> __alloc_pages: 0-order allocation failed (gfp=0xf0/0)
> __alloc_pages: 0-order allocation failed (gfp=0x1d2/0)
> VM: killing process httpd
>
> The memory leak is in the httpd process (thus in Apache, PHP or my
> scripts). It grows (within hours) to several hundreds (!) of MB. To
> limit the impact of the leaks I changed /etc/httpd/httpd.conf:
> MaxRequestsPerChild 10000
>
> This gave the system some breath: after this change the httpd
> processes only take a maximum of 12 MB (scripts may take 8 MB as
> configured in /etc/php.ini, the rest is probably taken by Apache).
>
> Does anyone of you guys know of existing memory leaks in the above
> Apache and PHP packages? It is possible that I have memory leaks in my
> script, but I don't understand why they are causing problems now
> (after running for over a year without problems).
>
> What are the common pitfalls in PHP scripts that can cause such big
> memory leaks?[/color]

You using the XML functions? They can cause this problem.


Closed Thread