Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2611816 bytes)
一段PHP程序执行报错:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2611816 bytes)
去百度了一下,原来是php.ini中的内存分配的问题,默认php代码能够申请到的最大内存字节数就是134217728 bytes,如果代码执行的时候再需要更多的内存,就会报错了,于是就将php.ini文件中的配置改了一下:
代码如下:
但是之后一想,一个php脚本一次请求的内存空间就要超过128M,那不管你以后将memory_limit设置成多大,以后肯定有出问题的时候。
究其原因,是我在在编码时,仅仅对变量赋值,却从来没有 unset ($var) 过。导致了内存占用越来越多,所以以后一个变量不再使用之后,一定要记得unset掉它。
protected function execute(InputInterface $input, OutputInterface $output)
{
//ini_set('max_execution_time', '0');
$answerService = new AnswerService();
$taskService = new TaskService();
$taskStudentService = new TaskStudentService();
$statService = new StatService();
$stuService = new StudentService(); $unMarkedStudents = $taskService->findUnMarkedStudent();
if(count($unMarkedStudents)>0){
foreach($unMarkedStudents as $taskStuInfo) {
$unMarkedQuestions = $taskService->findUnMarkedQuestion($taskStuInfo['taskId'],$taskStuInfo['studentId']);
foreach($unMarkedQuestions as $v){
$answerService->submitUnmarks($taskStuInfo['id'],$taskStuInfo['taskId'],$taskStuInfo['studentId'],$v['questionId'],
$v['subIndexes']);
}
//修改taskStudent表的status状态
$taskStudentInfo = $taskStudentService->get($taskStuInfo['id']);
$taskStudentInfo->updateTime = new \DateTime();
$taskStudentInfo->status = 'MARKED';
$taskStudentService->update($taskStudentInfo,true); unset($taskStudentInfo);
//生成该学生的趋势
$stuInfo = $stuService->get($taskStuInfo['studentId']);
$statService->calTaskPolyFit($stuInfo, $taskStuInfo['subject']);
unset($stuInfo);
unset($unMarkedQuestions);
}
} else {
return false;
}
}
完毕。
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2611816 bytes)的更多相关文章
- PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted 错误
php运行一段时间后,部分页面打不开,查看nginx日志里面一直在报PHP message: PHP Fatal error: Allowed memory size of 134217728 by ...
- Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 44 bytes) in
最近莫名出现这个错误. 研究一下原因很奇葩呢. 原因:sql获取数据库中数据,取出数据赋给变量,数据太多,超过memory_limit内存设置了. 解决方法:设置memory_limit不建议.优化代 ...
- Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in
解释是可用内存已耗尽,这关系到PHP的memory_limit的设置问题. 我在网上看到,有两种方法解决 1.修改php.ini memory_limit = 128 这种方法需要重启服务器,很显然, ...
- Fatal error: Allowed memory size of 524288000 bytes exhausted (tried to allocate 64 bytes) in D
Fatal error: Allowed memory size of 524288000 bytes exhausted (tried to allocate 64 bytes) in D 从数据库 ...
- Fatal error: Allowed memory size of 8388608 bytes exhausted
这两天安装bugfree,更换了一个数据量较大的库,结果打开bug详情页要么是空白页,要么就报如题的错误,错误信息还包括C:\wamp\www\bugfree\Include\Class\ADOLit ...
- (转载)PHP的内存限制 Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in
(转载)http://blog.csdn.net/beyondlpf/article/details/7794028 Fatal error: Allowed memory size of 13421 ...
- Allowed memory size of 134217728 bytes exhausted解决办法(php内存耗尽报错)【简记】
报错: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) i ...
- php的Allowed memory size of 134217728 bytes exhausted问题解决办法
php的Allowed memory size of 134217728 bytes exhausted问题解决办法 报错: Fatal error: Allowed memory size of 1 ...
- PHP的内存限制 Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in Fa ...
随机推荐
- 添加PMD插件扫描潜在的bug
上一节使用checkstyle来规范你的项目主要解决了代码编码规范问题,比如缩进换行等.这次继续代码健康工具类PMD. 什么是PMD PMD真的不像checkstyle这样的东西所见即所得啊,去官网找 ...
- CSS命名规范和规则
一.命名规则 ).尽量不缩写,除非一看就明白的单词 二.class的命名 (1).red { color: red; } .f60 {color: #f60; } .ff8600{ color: #f ...
- 带监督的文本分类算法FastText
该算法由facebook在2016年开源,典型应用场景是“带监督的文本分类问题”. 模型 模型的优化目标如下: 其中,$<x_n,y_n>$是一条训练样本,$y_n$是训练目标,$ ...
- 对象序列化与反序列化(二进制 byte[])
.序列化 public static byte[] SerializeObject(object obj) { if (obj == null) return null; MemoryStream m ...
- JAVA-Eclipse中web-inf和meta-inf文件夹
WEB-INF /WEB-INF/web.xml 你的Web应用程序配置文件,这是一个XML文件,其中描述了 servlet 和其他的应用组件配置及命名规则: /WEB- IN ...
- (转)[Unity3D]BuildPipeline.PushAssetDependencies 打包依赖包,优化UI Prefab的资源引用加载(坑爹之处)
转自:http://blog.csdn.net/chiuan/article/details/39040421#reply 1:长话短说,UI Prefab中一般会交叉引用Atlas,那么打包时候我们 ...
- XAML中特殊符号书写
XAML中特殊符号书写 表示换行. 表示空格.
- 1050: 贝贝的ISBN号码(isbn)
#include <iostream> #include <iomanip> #include <cstdlib> #include <string> ...
- (素材源代码) 猫猫学iOS 之UIDynamic重力、弹性碰撞吸附等现象牛逼Demo
猫猫分享,必须精品 原创文章,欢迎转载. 转载请注明:翟乃玉的博客 地址:http://blog.csdn.net/u013357243 一:效果 二:代码 #import "ViewCon ...
- RHEL/CentOS/Fedora各种源
CentOS 默认自带 CentOS-Base.repo 源, 但官方源中去除了很多有版权争议的软件, 而且安装的软件也不是最新的稳定版. Fedora 自带的源中也找不到很多多媒体软件, 如果需要安 ...