Yii2 Allowed memory size exhausted

前端 未结 2 1085
长发绾君心
长发绾君心 2021-01-19 12:47

I\'m uploading file to my Yii2 project. The file it self is ~100kB, contains ~45 000 short lines that are processed by controller and added line-by-line to the database.

2条回答
  •  天命终不由人
    2021-01-19 13:05

    The error isn't in this line. I had the same error when i had imported data from an excel file and logged some "models" data with print_r or var_dump where the whole "model" is added to the log (including relations traversing etc.)

    You can fix this by limiting the depth of the dump by using the Vardumper instead of print_r or var_dump and setting a depth (e.g. 3)

    yii\helpers\VarDumper::dumpAsString($var, $depth, $highlight)
    

    Then only the code is returned to this depth and the log would getting smaller.

    Also if you have many inserts / updates to your database the log will get pretty long.

    The problem btw comes from the debug toolbar. You wouldn't get the error if the debug module is disabled.

    but other then increasing the memory there isn't real solution

提交回复
热议问题