Out of memory error in Laravel 5.3

无人久伴 提交于 2019-12-10 12:18:35

问题


There is an issue on Laravel 5.3 / Jesenger / MongoDB 3.0 which I reported here. The issue arises from saving or updating a field with special characters like "°ó" in mongodb, it always results in "out of memory" error.

Allowed memory size of ######### bytes exhausted (tried to allocate ********** bytes) 
//Whereas ######### is always greater than **********

My question is how can I convert the special character so that they can be safely pushed into the database. Note: I am doing batch insert and updating of like 30000 records, a good solution may put this into consideration.

// Code Sample
<?php 
class Products extends Jessenger\Mongodb\Eloquent\Model
{

}
?>
$product = new Products();
$product->name = 'Akara';
$product->sku = 'naija001';
$product->description = 'special characters like °ó in mongodb';
$product->save(); // Throws allowed memory size of 1392394984 bytes 
                  // exhausted (tried to allocate 2195914) note that 
                  // allowed memory size is greater than the allocated size

My temporal fix

$product = new Products();
$product->name = 'Akara';
$product->sku = 'naija001';
$product->description = utf8_encode('special characters like °ó in mongodb');
$product->save(); // Saved successfully

来源:https://stackoverflow.com/questions/51090688/out-of-memory-error-in-laravel-5-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!