php cli memory limit
Solution 1:
IIRC, an unlimited memory_limit isn't supported by the CLI (I'll try to find a source for this) but for now, try passing it into the command:
php -d memory_limit=128M my_script.php
UPDATE
Apparently I was dreaming about the unlimited memory_limit not being supported for php cli. Regardless, it looks like the value from the ini is ignored. The simplest solution should then be to specifically set it in the php command calling the script.
UPDATE2
To answer the question of where the memory limit is coming from, it's most likely being set in the script itself using 'ini_set'.
Solution 2:
While testing a CLI php version 5.5.9
it appears that in cli it has unlmited memory limit by default, and specifying php -d memory_limit=4G my_script.php
will set a limitation to that.