dqxmf02844 2016-03-29 06:19
浏览 169

允许的内存大小为100663296字节耗尽(试图分配32个字节)

Using with command in yii give memory error.When I use 3 tables it works fine. As I add 4th then it starts give an error on server. Locally it works fine

$criteria->with = array('users0','businessUnits','skills','questions');
$criteria->together = true;

$models = Company::model()->findAll($criteria);

It gives an error Allowed memory size of 100663296 bytes exhausted (tried to allocate 32 bytes) in

  • 写回答

1条回答 默认 最新

  • dstwfcz1377 2016-03-29 06:24
    关注

    Problem - Fatal error: Allowed memory size of 33554432 bytes exhausted

    Reason for Fatal error: Allowed memory size of X bytes exhausted

    Recently I have encountered this error with one of my php application. Like any other programmer I thought of googling the issue.

    After some research I came to find that for some reason my script is taking all the memory space. As I was on shared hosting & ini_set was disabled by the server admin.

    I had no other option than finding the root cause of the issue.

    Incorrect Solution: Solutions such as increase the memory is not the correct solution. By that you are allowing your bad script to consume all the memory.

    So how to solve the issue?

    Suppose you are creating a variable that is carrying so much data. In loop you are reassigning value to that.

    So you reassign too much data to a same variable, though its values are getting updated but memory is not getting freed yet as variable is in use & garbage collector is not clearing that memory.

    Correct Solution: To avoid Allowed memory size exhausted error you can set the value to null. By doing so you are telling garbage collector whatever kept in memory for that variable is not required & freed. Garbage collect will immediately clear the space.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。