开发者

Symfony Max Allowable Size Error

开发者 https://www.devze.com 2022-12-21 17:40 出处:网络
I just scaffolded a new module and when I save using the generated form 开发者_开发技巧I get: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 19456 bytes) in /Applicati

I just scaffolded a new module and when I save using the generated form 开发者_开发技巧I get:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 19456 bytes) in /Applications/MAMP/htdocs/ats/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Hydrator/Graph.php on line 404

Any ideas why?


symfony is quite greedy for memory, so this sometimes happens. You can increase the memory available to PHP/symfony via php.ini as suggested above:

php.ini:

memory_limit = 128M

128M here is just an example, but one which you might need to evaluate.


because that's the configured memory limit of your php. you may want to find what php.ini it uses from phpinfo() and edit it to give symfony more memory.


The memory_limit is the maximum amount of memory a PHP script is allowed to use. Basically, this is a security configuration option, to ensure you don't have a PHP script that does mad and consumes all the memory of the server -- or worse, that you don't have several PHP script that eat more memory than the server has.


This configuration directive can be set in the php.ini file ; it's the file that sets the configuration of PHP.

To find out where the php.ini file is on your server, you can use the phpinfo() function : somewhere near the top of the output, there should be a "Loaded Configuration File" option.


Which value should be used for memory_limit is an interesting question... In the past, when we were only writting small script, 8MB was generally enough.

Now, with Frameworks, bigger applications structured in layers, ORM, and all that, 8MB is generally not enough (as you obviously noticed) -- I generally set memory_limit to 32M on my production servers, which is almost always enough for my applications, without being too much.

So, in my php.ini file, I have :

memory_limit = 32M


Note : it would be tempting to put a very high value for memory_limit, to just get rid of the problem... But remember that memory_limit is here as a security : you should make sure your server has enough memory to answer several requests at the same time !

0

精彩评论

暂无评论...
验证码 换一张
取 消