小编Bob*_*nes的帖子

如何在运行长PHP脚本时清除内存?尝试unset()

我的脚本将excel文件导入到产品数据库中以更新数量新产品等....

我有内存问题,我尝试将内存限制提高到最大值(800MB +).我已经尝试取消设置变量以释放循环之间的内存,但我仍然耗尽内存.我已经尝试将超时设置为无限但它绝对是一个内存问题.

来自日志文件的错误消息:致命错误:允许的内存大小为851443712字节耗尽(尝试分配71个字节)

这些脚本都不包含在函数中.如果我在函数内部创建main for循环并重复调用该函数将有助于垃圾收集和清理内存?任何帮助或指导将不胜感激.

导入脚本:

error_reporting( E_ALL & ~E_NOTICE );
ini_set('memory_limit', '812M');
set_time_limit(0);

/* Config Start */
define('BasePath', '/home/xxxxx/public_html');
define('CfgMagentoPath',                    BasePath);
define('CfgCategoryMapDBxls',                   BasePath."/xxxx/Shdddddd.xls");
define('CfgVenderDBxls',                    BasePath."/xxxx/xxxxxx.xls");
define('CfgReportEmail',                    "xxxxxx@gmail.com");
/* Config End */

require_once(CfgMagentoPath . '/app/Mage.php');
Mage::app(); 
//$app = Mage::app('default'); 
//Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
require_once(BasePath.'/xxxxx/xxxx/libs/mage.func-inc.php');
require_once(BasePath.'/xxxxx/xxxxx/libs/excel-read.class.php');

//Alert Arrays
$AAnotmapped        = array();
$AAnewproducts  = array();
$AApriceupdated = array();
$AAimgerror         = array();
$PriceErrors        = array();

$SkipCat = false;

//Create Mapped Cats - In Magento

$excel = new ExcelReader(CfgCategoryMapDBxls,"UTF-8");
$CM = $excel->getWorksheetData('Sheet1');
if(!$SkipCat){
    echo "========   Generating …
Run Code Online (Sandbox Code Playgroud)

php mysql

18
推荐指数
2
解决办法
4万
查看次数

标签 统计

mysql ×1

php ×1