You can change the memory limit globally in php.ini, look for this line: 

***memory_limit =***

 and adjust the value acording to your needs, also you can do it in line in any given file you want like this:

    ini_set("memory_limit","1G");