I had some problem with a script that needed more memory to be executed and was using ini_set(‘memory_limit’, ‘50M’). For some reasons the memory was not incremented as expected.
After googleing around for a solution I just had an intuition: could be suhosin? Indeed, the problem was in the suhosin module that is enable by default on Ubuntu: it does not allow to redefine the memory limit over the limit specified in the php.ini file.
To make ini_set work normally under Ubuntu, comment out the suhosin extension in /etc/php5/apachew/conf.d/suhosin.ini