简体   繁体   English

Symfony2:渲染器中的内存耗尽

[英]Symfony2: memory exhausted in the renderer

I have a page in Symfony2 that display a list of search result in a table. 我在Symfony2中有一个页面,该页面在表中显示搜索结果列表。 I use the JS library gridify to display the result so I have no troubles with the browser, but with Symfony2. 我使用JS库gridify来显示结果,因此我对浏览器没有任何麻烦,但是对Symfony2来说,没有问题。

When I have many results (eg 40 000), I have an exception 当我有很多结果(例如40 000)时,我有一个例外

php.CRITICAL: Fatal Error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 59233802 bytes) 

thrown from PhpEngine->evaluate which does: 从PhpEngine-> evaluate抛出的结果是:

ob_start();
require $this->evalTemplate;
$this->evalTemplate = null;
return ob_get_clean();

The memory exception occures on ob_get_clean. 内存异常发生在ob_get_clean上。 I think that the included template is too huge to be included. 我认为包含的模板太大,无法包含在内。 The memory limit is currently to 512M, I don't want to increase it once more (but with 1024M I have no more problems). 当前的内存限制为512M,我不想再增加它(但是使用1024M时,我没有更多问题了)。

Is there any way (proper or not) in Symfony2 to bypass it? Symfony2中有什么方法(正确与否)绕过它?

Technically you can increase the memory_limit at runtime with this line of code: 从技术上讲,您可以使用以下代码在运行时增加memory_limit:

ini_set('memory_limit', '1024M')

but the hosting provider may have put in place some ways to prevent that. 但是托管服务提供商可能已经采取了一些措施来防止这种情况。

Anyway, as other have suggested, you may want to find out why so much memory is consumed and possibly optimize the whole process. 无论如何,正如其他人所建议的那样,您可能想找出为什么要消耗这么多内存并可能优化整个过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM