ini_set('memory_limit', ...) doesn't work and returns false; can't figure out why
Asked Answered
C

2

6
ini_set('memory_limit', '128M'); // Returns false; memory_limit unchanged

I wasn't able to find a list of things that can cause this. So far I checked:

  • Safe mode: disabled
  • disable_functions: Empty
  • php_admin_value: None that I could find (is there a way to know for sure?)

I ran out of ideas! ini_set works correctly with other parameters (such as "display_errors")

Chez answered 2/5, 2011 at 16:58 Comment(6)
which version of PHP are you using?Galliwasp
Does it fail for any directive passed to ini_set() or just memory_limit? Does any value for memory_limit fail, or just 128M? How are you verifying that the value is unchanged? I have noticed this behavior on a couple of servers over here as well, so I am very interested to see if we are experiencing the same problem.Duppy
are you using a shared hosting platform or is this a machine you setup/configured yourself?Galliwasp
@James: I am using PHP Version 5.2.6-1+lenny9.Chez
@Phoenix: it fails only with memory_limit. I verify that the value is unchanged by calling ini_get.Chez
@James question 2: This is a dedicated server our network administrator set up. This is our dev server where we test our code; on the live servers, ini_set works correctly.Chez
G
7

If it's not the PHP version problem posted already try checking that there's nothing on the machine preventing your from raising this limit.

How to check whether Suhosin is installed?

edit (after establishing that Suhosin is installed):

Config details are here: http://www.hardened-php.net/suhosin/configuration.html I suspect there'll be a file in /etc/php.d/ that you can edit to increase the memory limit bounds. The config variable you need to edit is: suhosin.memory_limit

Galliwasp answered 2/5, 2011 at 17:10 Comment(3)
Bingo! This server is protected with the Suhosin Patch 0.9.10.. Now what is it? I'll try to google it and see if it's the problem or notChez
Well it's probably this, but I can't find a setting option that says "never go higher than 64M".. Do you know where it may be configured? Or it works this way by default? In any case I opened a ticket for our network admin hopefully he'll be able to sort this outChez
ok, our network admin changed the sushosin option and now it works. tyChez
G
1

The manual says :

Prior to PHP 5.2.1, in order to use this directive it had to be enabled at compile time by using --enable-memory-limit in the configure line

That might be the cause of your problem.

Garner answered 2/5, 2011 at 17:7 Comment(1)
We use: PHP Version 5.2.6-1+lenny9, so "unfortunately" it's not the problem =(Chez

© 2022 - 2024 — McMap. All rights reserved.