Do you have access to the php.ini file? Then change the memory_limit value there.
You should also analyze your script. Lots of database transactions? Many of them in loops? Lots of loops? Lots of temporary variables? A clever usage of unset can make a huge difference.
Also nice to know: Performance Considerations and Garbage Collection
Edit (a possible answer to your question why memory_limit
doesn't work with ini_set
)
memory_limit integer This sets the
maximum amount of memory in bytes that
a script is allowed to allocate. This
helps prevent poorly written scripts
for eating up all available memory on
a server. Note that to have no memory
limit, set this directive to -1.
Prior to PHP 5.2.1, in order to use
this directive it had to be enabled at
compile time by using
--enable-memory-limit in the configure line. This compile-time flag was also
required to define the functions
memory_get_usage() and
memory_get_peak_usage() prior to
5.2.1.
When an integer is used, the value is
measured in bytes. Shorthand notation,
as described in this FAQ, may also be
used.
source: php.net