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 ...
随机推荐
- CSDN日报20170226——《你离心想事成仅仅差一个计划》
[程序人生] 你离心想事成仅仅差一个计划 作者:安晓辉 从目标怎样导出工作计划.我们会以"出版一本小说"为例来解说计划的形成过程. 在開始之前.我们先来说明一个概念:目标的两种类型 ...
- Android -- Camera.ShutterCallback
干货 相机拍照的回调 /** * Equivalent to takePicture(shutter, raw, null, jpeg). * * @see #takePicture(ShutterC ...
- Centos6.4下安装protobuf-c问题及解决办法
1.前言 protobuf是Google提供的结构持久化工具,类型XML,但要比XML更加灵活,效率要高.protobuf当初支持C++.JAVA和Python,后来有了支持C语言的Protobuf- ...
- OPENGL: WHY IS YOUR CODE PRODUCING A BLACK WINDOW?
Introduction One of the most common problems for novice, and sometimes experienced, OpenGL program ...
- String escape/unescape into XML
Is there any C# function which could be used to escape and un-escape a string, which could be used t ...
- Redis实战总结-Redis的高可用性
在之前的博客<Redis实战总结-配置.持久化.复制>给出了一种Redis主从复制机制,简单地实现了Redis高可用.然后,如果Master服务器宕机,会导致整个Redis瘫痪,这种方式的 ...
- 无法ping通自身
今日,ping localhost 超时,ping 127.0.0.1 显示一般故障.无法访问自己电脑上的tomcat.... 居然,居然是防火墙打开了,关了就好了.我勒个去!!!!
- 一步一步教你搭建和使用FitNesse
啄木鸟之家大吕 敏捷测试已成为现在式,尽早和持续的反馈成为各研发团队的必选项.测试同学也需要跟上这个趋势.除了“找bug”.“分析需求”.“功能测试”,还需考虑“交付质量.一次做对.在没有用户界面情况 ...
- 使用CocoaPods来做iOS程序的包依赖管理
前言 每种语言发展到一个阶段,就会出现相应的依赖管理工具, 或者是中央代码仓库.比如 Java: maven,Ivy Ruby: gems Python: pip, easy_install Node ...
- Android 演示 Android ListView 和 github XListView(3-3)
本文内容 环境 项目结构 演示 1:简单 XListView 演示 2:XListView + Fragment 演示 3:XListView + ViewPager + Fragment 本文三个演 ...