PHP scripts causing (big!) memory leaks??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maurice

    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 (root@Pentium.s use.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:
    MaxRequestsPerC hild 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.

    #2
    Re: PHP scripts causing (big!) memory leaks??


    "Maurice" <spam@debijl.ne t> wrote in message
    news:2b4a26d0.0 309152253.18fa0 12a@posting.goo gle.com...[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.s use.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:
    > MaxRequestsPerC hild 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).


    Comment

    • Jon

      #3
      Re: PHP scripts causing (big!) memory leaks??

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


      "Maurice" <spam@debijl.ne t> wrote in message
      news:2b4a26d0.0 309152253.18fa0 12a@posting.goo gle.com...[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.s use.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:
      > MaxRequestsPerC hild 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]


      Comment

      • Jon Kraft

        #4
        Re: PHP scripts causing (big!) memory leaks??

        Maurice <spam@debijl.ne t> 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:
        > MaxRequestsPerC hild 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

        Comment

        • gortonc

          #5
          Re: PHP scripts causing (big!) memory leaks??


          "Maurice" <spam@debijl.ne t> wrote in message
          news:2b4a26d0.0 309152253.18fa0 12a@posting.goo gle.com...[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.s use.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:
          > MaxRequestsPerC hild 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.


          Comment

          Working...