Allowed memory size of 134217728 bytes exhausted解决办法(php内存耗尽报错)【简记】
报错:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in。。。
解析:
134217728/1024/1024 = 128
解释:
内存已耗尽,这关系到PHP的memory_limit的设置问题,根据自己的需要及参考本机的内存大小修改php内存限制。
这里有三种解决方案 :
1、修改php.ini (改配置)
memory_limit = 128
这种方法需要重启服务器,很显然,此方法对虚拟机有限制。
2、通过ini_set函数修改配置选项值 (改代码)
ini_set (‘memory_limit’, ‘128M’) ;
3、直接取消PHP的内存限制(改代码)
ini_set ("memory_limit","-1");
值得注意的是:如果通过上面的方式修改后还会报这个错误,那你要检查一下你写的代码是否存在效率问题。(举例:从数据库查询到的数据加载到内存里面,然后php 进行数据处理,如果代码写的不是很严谨存在效率问题,特别是数据量非常大的时候也会导致内存耗尽)
本人遇到这个问题就是因为最开始做公司后台管理系统某个统计功能的时候代码写的不是很严谨,导致后来数据量达到一定量后,出现了内存耗尽。当然咯,自己留的坑最后还得自己填上。本人最终通过重构之前的代码,优化了代码执行效率,解决了内存耗尽问题。
---------------------
参考资料:https://blog.csdn.net/qdujunjie/article/details/43672579
Allowed memory size of 134217728 bytes exhausted解决办法(php内存耗尽报错)【简记】的更多相关文章
- 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
(转载)http://blog.csdn.net/beyondlpf/article/details/7794028 Fatal error: Allowed memory size of 13421 ...
- 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 ...
- 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 ...
- Allowed memory size of 134217728 bytes exhausted
错误信息: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65015808 bytes) 由于报错信息和数据库 ...
- php的Allowed memory size of 134217728 bytes exhausted问题
提示Allowed memory size of 134217728 bytes exhausted,出现这种错误的情况常见的有三种: 0:查询的数据量大. 1:数据量不大,但是php.ini配置的内 ...
- 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 261181 ...
- Allowed memory size of 134217728 bytes exhausted (tried to allocate 2 bytes)
出现 Allowed memory size of 134217728 bytes exhausted (tried to allocate 2 bytes)时在php.ini文件中配置 memor ...
- Allowed memory size of 134217728 bytes exhausted问题解决方法
Allowed memory size of 134217728 bytes exhausted问题解决方法 php默认内存限制是128M,所以需要修改php.ini文件. 查找到memory_lim ...
随机推荐
- mac openresty 源码安装 坑
下载openresty源码安装 下载页面http://openresty.org/cn/download.html 下载上一个版本的稳定版 https://openresty.org/download ...
- Jenkins时区设置为北京时间
打开 [系统管理]->[脚本命令行]运行下面的命令 System.setProperty('org.apache.commons.jelly.tags.fmt.timeZone', 'Asia/ ...
- npm 包的 发布 流程
npm 包的发布流程 本文主要是针对 还未曾发布过自己的 npm 的同学,阐述一下 npm 的发布流程 熟悉的同学,可以绕道了. 首先你得有一个 自己的 npmjs.com 的账号 (没有的话,就到 ...
- Python的魔法函数
概要 如何定义一个类 类里通常包含什么 各个部分解释 类是怎么来的 type和object的关系 判断对象的类型 上下文管理器 类结构 #!/usr/bin/env python # -*- codi ...
- PHP自动加载机制
类的载入共经历了三个阶段 第一阶段是面向过程式的做法,整个项目里到处都是include或require. 问题:难看,不易维护. . 第二阶段是魔术方法__autoload,当new一个类的时候,如果 ...
- 初学Java Web(2)——搭建Java Web开发环境
虽然说 html 和 css 等前端技术,是对于 Web 来说不可或缺的技术,但是毕竟更为简单一些,所以就不详细介绍了,没有基础的同学可以去菜鸟教程或者W3school进行自主学习,最好的方式还是做一 ...
- C语言实现链队列的初始化&进队&出队
/*链表实现队列的一系列操作*/ #include<stdio.h> #include<stdlib.h> #define OK 1 #define ERROR 0 typed ...
- kubernetes系列03—kubeadm安装部署K8S集群
本文收录在容器技术学习系列文章总目录 1.kubernetes安装介绍 1.1 K8S架构图 1.2 K8S搭建安装示意图 1.3 安装kubernetes方法 1.3.1 方法1:使用kubeadm ...
- Spring拓展接口之BeanFactoryPostProcessor,占位符与敏感信息解密原理
前言 开心一刻 一只被二哈带偏了的柴犬,我只想弄死隔壁的二哈 what:是什么 BeanFactoryPostProcessor接口很简单,只包含一个方法 /** * 通过BeanFactoryPos ...
- C指针和数组的关系详解
1.C中数组和指针的关系 对于任意类型的数组arr,对于同类型的指针类型parr(确切一点,可以假设类型为int,即int arr[], *parr).它们之间有如下"内幕": 1 ...