(转载)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
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in
解释是可用内存已耗尽,这关系到PHP的memory_limit的设置问题。
这里有两种方法解决
1、修改php.ini
memory_limit = 128
这种方法需要重启服务器,很显然,此方法对虚拟机有限制。
2、通过ini_set函数修改配置选项值
ini_set ('memory_limit', '128M')
ini_set ('memory_limit', '128M')
----------------
PHP5中,对于memory_limit的设定已经从以往的8M扩大到128M的上限。对于配置中的定义解释是: memory_limit = 128M ; Maximum amount of memory a script may consume (128MB) 最大单线程的独立内存使用量。也就是一个web请求,给予线程最大的内存使用量的定义。现有的大部分网站或者论坛应用中,应用软件的配备一般都是以如下的形式搭建: Nginx(Apache)+PHP+Memcache+Mysql 对于以上的应用软件的采用,优点我就不再多说。但对于Memcache的使用就是为了减少对于数据库的访问的频率的降低,也是提高服务响应的一种办法。但是对于memcache和数据库的数据存储有区别的是,memcache的数据并不是以上数据的形式存储在内存中,而是抽象化了之后以字符的形式,hash表的形式存储在内存之中。这样的存储区别导致,每次memcache的数据抽取必须全部数据反序拟化一次,将所有的数据导入进独立的单一线程中,然后第二部才是进行过滤和抽取你所需要的数据。在应用过程中,如果是读取数据库的数据,大家应该知道,优化的办法应该是在SQL语句中比保证第一次过滤尽量是提高准确性,只取需要的字段,不要全部所有字段取出之后再在应用中过滤得到自己想要的字段,这样对于服务器的负载会有本质的区别。
如果采用memcache,必然做不到数据库在在第一次就精确过滤这点目标。那么就需要在开始设计表的同时就需要考虑到这点,尽量保证被memcache数据表尽量保证数据的较少,可以多分表来完成。
memory_limit的内存分配,标配是128M。一旦独立的线程超过了128M,那PHP会报错: Fatal error: Allowed memory size of 33554432 bytes对于8G内存的服务器,如果同时并发的响应达到50,每个都是128M的峰值,那估计也是服务器会卡死的时候。
尽量降低128M的内存配置,如果调整至64M,服务器的负载基本能下降一半左右,如果能调整至32M效果更好。但是对于应用的要求就更高,很多表建立初期就没有考虑到这个问题,如果你要采用memcache作为数据的存储,必须提前完成优化数据表的设计部署,降低独立线程PHP的内存使用量,服务器的响应和负载降低的就不仅仅是几个百分点的效果了。
(转载)PHP的内存限制 Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in的更多相关文章
- 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 ...
- Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in
解释是可用内存已耗尽,这关系到PHP的memory_limit的设置问题. 我在网上看到,有两种方法解决 1.修改php.ini memory_limit = 128 这种方法需要重启服务器,很显然, ...
- 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 解决办法
PHP内存溢出Allowed memory size of 解决办法 博客分类: php ============================Allowed memory size of x ...
- 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 从数据库 ...
- 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问题解决办法
php的Allowed memory size of 134217728 bytes exhausted问题解决办法 报错: Fatal error: Allowed memory size of 1 ...
- 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 ...
随机推荐
- git 使用小结
git git是一个分布式版本控制系统,主要用于多人协作.可以将自己的代码托管到github上. 常用的几个命令 git pull 拉取别人的修改到本地,如果拉取内容和本地所作的修改存在冲突,git会 ...
- resid入门笔记(二)
本节介绍redis 消息订阅 密码 持久化 主从配置 首先我对消息订阅理解的不深,应该说仅知道概念吧 发送消息 cctv1 发送 hello cctv2 发送 ‘你好’ client ...
- 第二章 Qt常用工具的介绍
第二章 Qt常用工具的介绍 (1)No.1 qmake 相信编写过Makefile的开发人员,随着工程中源码的级数递增和以类型.功能.模块组织源码的子目录的增多,都不愿意重复机械地手工编写这个工程管理 ...
- iOS网络编程总结
好长时间没有进行更行了,最近学到AFNetworking框架,在学习完成之后做出一个总结 1.第三方网络的框架 AFNEtworking使用简单,对最新的iOS特性都有很好的支持,对NSURL进行了封 ...
- django引用static目录下的css,js文件304问题
前提:django1.8 在html页面可以请求道css,js文件并在chrome的开发者工具中查看css,js文件返回状态为200 原因: html页面在头部添加了<!DOCTYPE html ...
- struct--file_operations
struct--file_operations----------------------------------------- struct file_operations是一个字符设备把驱动 ...
- codeforces 633D - Fibonacci-ish 离散化 + 二分查询
Fibonacci-ish Yash has recently learnt about the Fibonacci sequence and is very excited about it. He ...
- Sublime Text 3插件之SublimeTmpl:新建文件的模版插件
SublimeTmpl能新建html.css.javascript.php.python.ruby六种类型的文件模板,所有的文件模板都在插件目录的templates文件夹里,可以自定义编辑文件模板. ...
- 成为Java GC专家(3)—如何优化Java垃圾回收机制
为什么需要优化GC 或者说的更确切一些,对于基于Java的服务,是否有必要优化GC?应该说,对于所有的基于Java的服务,并不总是需要进行GC优化,但前提是所运行的基于Java的系统,包含了如下参数或 ...
- caffe之(五)loss层
在caffe中,网络的结构由prototxt文件中给出,由一些列的Layer(层)组成,常用的层如:数据加载层.卷积操作层.pooling层.非线性变换层.内积运算层.归一化层.损失计算层等:本篇主要 ...