Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts

    Question memory_limit not being recognized

    Hi all,

    On my development machine, I am running PHP 5.2 under Apache 2 on Debian Etch.

    I have auto-updates turned on in Debian (so that apt-get will prompt me when a newer version of anything turns up).

    Anyway, I had been using PHP 5.0 and the other day I upgraded via the Debian server to 5.2.

    All well and good.

    Now, ages ago (under PHP 5.0), I ran into a memory limit error when using PHP CLI, so I changed the memory limit from 16 to 32 MB, and all was good. (Note that the Apache2 limit can remain at 16).

    About an hour ago, lo and behold, I ran into the same error again! I checked the /etc/php5/cli/php.ini file - nope it's still the same as before: "memory_limit = 32M".

    So I ran "php -i" from the command line and as part of it's output, I get the following:

    Firstly:
    Configuration File (php.ini) Path => /etc/php5/cli (yep, that's what I would expect).

    But then:
    memory_limit => 16M => 16M

    What the hell ?! It tells me it is looking at /etc/php5/cli to get it's configuration, and in that file I have set the memory limit to 32MB, but it still tells me its 16MB?

    I double-checked against the output from my code: Fatal error: Allowed memory size of 16777216 bytes exhausted ... and yep, 16777216/(1024*1024) = 16MB.

    Any suggestions will be gratefully received!

    TIA,
    Mike.

    EDIT: I have checked the PHP documentation and it says that the memory_limit directive has no effect in versions earlier than 5.2.1 unless the -enable-memory-limit option is included at compile time. I am using version 5.2.0-8 ... so I can only assume that that option was not included by the Debian people at compile time ... but obviously it was included when they built version 5.0. So why the blue buggery blazes would they switch the damn thing off in the newer version ???!!!!!

    EDIT 2: I have found the following work-around: php -d memory_limit=32M -f myscript.php. That would suggest that -enable-memory-limit was included at build time, but it still doesn't explain why PHP is not picking up my changes in php.ini! So I have to manually set the memory limit each time I call the script. Not onerous, but a pain in the arse and I would like to get to the bottom of this. All ideas welcome
    Last edited by mlse; 05-12-2009 at 01:04 PM. Reason: Additional Info
    Die Welt ist ein Irrenhaus und hier ist die Zentrale!

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    have you tried running phpinfo() to see what that says? It should tell you the location of the ini file its using and will list local and master values for all the settings.

  • #3
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts
    Hi, yep, I have tried that! It says 16Mb and it points to the file that I have edited to set the limit to 32Mb This has always worked for me before, and it's such a simple thing that I am completely stumped! phpinfo() is equivalent to "php -i" in cli mode.
    Last edited by mlse; 05-12-2009 at 03:39 PM.
    Die Welt ist ein Irrenhaus und hier ist die Zentrale!

  • #4
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    This may sound stupid but you are restarting apache aren't you?
    You can not say you know how to do something, until you can teach it to someone else.

  • #5
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts
    Yes, I have tried that. Anyway, the problem is with cli and not apache2, so it shouldn't matter.
    Die Welt ist ein Irrenhaus und hier ist die Zentrale!

  • #6
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Quote Originally Posted by mlse View Post
    Yes, I have tried that. Anyway, the problem is with cli and not apache2, so it shouldn't matter.
    Ah ok i just know when i make changes to my php.ini i have to restart apache for them to take effect (or at least that's what i seem to have to do). was just checking.
    You can not say you know how to do something, until you can teach it to someone else.

  • #7
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts
    Yep, that will affect scripts run on the server - but if you're running it from the command line, it uses a different .ini file which is independent of the server.
    Die Welt ist ein Irrenhaus und hier ist die Zentrale!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •