【发布时间】:2011-05-12 01:09:20
【问题描述】:
我在 PHP 中执行一个程序,有时会出现以下错误。这是由于创建了很多对象而没有破坏它们还是任何其他原因?
允许的内存大小为 16777216 字节已用尽(尝试分配 19456 字节) 在 PHP5 中销毁对象的正确方法是什么。
一些代码:
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);
}
}
【问题讨论】:
-
App::import('Vendor','GoogleShipping' ,array('file'=>'googlecheckout'.DS.'library'.DS.'googleshipping.php')); App::import('Vendor','GoogleTax' ,array('file'=>'googlecheckout'.DS.'library'.DS.'googletax.php'));类购物车{ var $_itemname;变量 $_unit_price;
-
公共函数用例($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);}
-
我导入的每个类也会创建一些对象
-
您可以使用编辑按钮 (stackoverflow.com/posts/4215324/edit) 编辑您的帖子,然后请将代码块中的代码附加到您的帖子中
标签: php object memory garbage-collection