Reputation: 155
When I try to upload file with PHP(CakePHP) application, those error happened.
Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 9660 bytes) in /home/xsu0653/public_html/administer/app/models/behaviors/sf_upload.php on line 156
As you can see, in my php.ini setting, allowed memory limit is set to 16MB.
This error message says my application tried to allocate only 9660 bytes. I think 9,660 bytes is only 0.009MB.
I can't understand why this error happend with such a little memory allocate. And this error not happen in any time, only some times. It's strange too.
Upvotes: 1
Views: 254
Reputation: 8706
PHP dynamically allocates memory as it runs through a script - it also tries to deallocate as it goes, too.
This error message says my application tried to allocate only 9660 bytes.
The 9660 bytes in your error message simple refer to the latest allocation - think of it like the proverbial straw breaking the camel's back. Your script has already allocated very close to your configured limit, and then tries to allocate this last little bit which puts it over the limit and so presents this error.
Frameworks like Cake can be rather inefficient in memory usage, depending on which modules are in use - and you will find that they recommend upping the limit.
You can also help to improve things by unsetting large arrays or clearing buffers when you no longer need them.
Upvotes: 0
Reputation: 1479
That is in reference to the amount it attempted to allocate and failed. It went 9,660 bytes over the limit.
Upvotes: 3