469,271 Members | 1,466 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

PHP scripts causing (big!) memory leaks??

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 (ro**@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?
Jul 16 '05 #1
4 16391

"Maurice" <sp**@debijl.net> wrote in message
news:2b**************************@posting.google.c om...
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 (ro**@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?


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).
Jul 16 '05 #2
Jon
Most likely it's your scripts. Are you doing large database operations,
etc?
"Maurice" <sp**@debijl.net> wrote in message
news:2b**************************@posting.google.c om...
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 (ro**@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?

Jul 16 '05 #3
Maurice <sp**@debijl.net> wrote:
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:
[snip] 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 [snip]
What are the common pitfalls in PHP scripts that can cause such big
memory leaks?


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

Jul 17 '05 #4

"Maurice" <sp**@debijl.net> wrote in message
news:2b**************************@posting.google.c om...
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 (ro**@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?


You using the XML functions? They can cause this problem.
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Robert | last post: by
2 posts views Thread by Generic Usenet Account | last post: by
5 posts views Thread by Valerie Hough | last post: by
3 posts views Thread by Bhargavan | last post: by
2 posts views Thread by ASP.Confused | last post: by
2 posts views Thread by James Hunter Ross | last post: by
3 posts views Thread by Jim Land | last post: by
13 posts views Thread by Ilias Lazaridis | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.