ini_set per cambiare il valore del memory_limit:
http://it.php.net/ini_set
http://it.php.net/manual/it/ini.core...i.memory-limit