dongxi1943 2010-11-18 13:39
浏览 15
已采纳

在php中销毁对象

I am executing a program in PHP and getting the below error sometimes.Is this due to creating lot's of objects and not destroying them or any other reason?

Allowed memory size of 16777216 bytes exhausted (tried to allocate 19456 bytes) What is the correct method to destroy an object in PHP5.

Some code:

App::import('Vendor','GoogleShipping',array('file'=>'googlecheckout'.DS.'library'.DS.'googleshipping.php'));
App::import('Vendor','GoogleTax',array('file'=>'googlecheckout'.DS.'library'.DS.'googletax.php'));
class Cart{
    var $_itemname;
    var $_unit_price;
    public function Usecase($itemname,$unit_price,$url,$merchant_private_item_data)
    {
            $cart = new GoogleCart($this->_merchant_id, $this->_merchant_key, $this->_server_type,$this->_currency);
            $item_1 = new GoogleItem($this->_itemname,$this->_item_description,$this->_total_count,$this->_unit_price,$this->_merchant_private_item_data);
    }
}
  • 写回答

4条回答 默认 最新

  • douping6871 2010-11-18 13:51
    关注

    Without seeing the code, we can't tell exactly what is causing this error. It could be creating too many objects, but it could just as easily be creating too big an array or other data.

    Either way regardless of what type of data you're creating that is throwing the error, it's likely to be a loop or recursive function running out of control that's the underlying cause, creating new data on every iteration, rather than you deliberately creating enough objects to overflow that much memory.

    If you really do need to create enough data to fill that much memory then you can modify the maximum memory allowance in PHP.ini, but it's unlikely.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀