Had a funny problem at work today, my php.ini was set to 1G however the script would still fail saying it couldn’t allocate 32bytes of memory which was a bit odd. A little investigation showed that at lib/php/phing/Phing.php
// should return memory limit in MB
$mem_limit = (int) ini_get('memory_limit');
if ($mem_limit < 32) {
// We do *not* need to save the original value here, since we don't plan to restore
// this after shutdown (we don't trust the effectiveness of PHP's garbage collection).
ini_set('memory_limit', '32M'); // nore: this may need to be higher for many projects
}
contained this interesting bit of code, so (int) ini_get('memory_limit') return 1 instead of something more sensible. Pretty failsome way to detect how much memory is allocated, assuming the entire world would be setting the memory in megabytes. Why is our php.ini set to 1G is another story.
