Q:

PHP using too much memory

I'm getting the following error when trying to run a php script I wrote:

Fatal error: Allowed memory size of
  33554432 bytes exhausted (tried to
  allocate 56320 bytes) in
  /home/evergrf2/public_html/ianburris/p/maptile/mapfetcher.php
  on line 43

What confuses me is that it says the allowed memory size is 33554432 bytes and that when the script tried to allocate 56320 bytes of space the allowed memory was exhausted. How is this possible when 56320 is less than 33554432? Maybe I'm misinterpreting what this is saying...

A:

allocation of 56320 pushed you above the limit. Increase your limit in php.ini if needed. 
to be more clear dont read it as alocating 56320 is more than allowed 33554432. Instead read it as, while allocating 56320, we surpassed the limit of 33554432.
Modified: dont increase without properly debuging and making sure there are no memory leaks.

A:

It says that trying to allocate additional 56320 bytes caused memory exhaustion (so it already had at least 33498112 bytes allocated).

A:

33554432 bytes is 32MB, which is not huge.
You can increase PHP's memory limit (in php.ini, look for a line that reads 'memory_limit = 32M' and modify it appropriately). I generally use 128M for development and heavy number-crunching.
The other solution is to profile and rewrite your code to use less memory.

