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 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL