(转载)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 ...
随机推荐
- zookeeper_笔记
Zookeeper:(没看懂) http://cailin.iteye.com/blog/2014486/ http://agapple.iteye.com/blog/1184023 http://b ...
- 简单改造 starling 中的 AssetManager 让其更适合 批次加载纹理
API文档参考:http://doc.starling-framework.org/core/starling/utils/AssetManager.html 项目想以不改动starling的情况下对 ...
- rsync+inotity
rsync默认端口:873xinetd默认服务 inotify参数详解inotifywait-r:递归-q:只打印事件-m:始终监听事件--excludei:排除--timefmt:时间格式--for ...
- ASP.NET MVC Web API使用示例
上篇博客讲解rest服务开发时,曾经提到过asp.net mvc中的rest api,由于篇幅原因,没有在上篇博客中进行讲解,这里专门拿出来进行讨论.还是一样引用上次的案例,用asp.net mvc提 ...
- c#抽象工厂类
抽象工厂类的结构如下: 工厂 a=new 1工厂 抽象类A aa=a.createA() aa.create()==类A1.create() 抽象类B bb=a.createB() bb.get()= ...
- Missra开源前端框架
Missra开源前端框架,官方网址:http://framework.missra.com
- Android 之 悬浮窗
昨天研究Android的悬浮窗,遇到一个问题,研究了一天,总算找到结症了,原因非常坑人..... 问题是这样的,我想要将悬浮窗展现在桌面或其他应用之上,我的开发机子用的是MIUI,结果发现在机子上无论 ...
- The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'.
Exception when executing ) br is a binary reader. The data to peak is D000 (D0=208) The cause is, fo ...
- c++ 类的对象与指针
这里首先我们需区分一下指针数组和数组指针. 指针数组:int *p[4];它最终是个数组,只是这个数组存储的是4个指向int类型的指针. 数组指针:int (*P)[4];它最终是个指针,表示一个指向 ...
- strstr函数与strcmp函数
1.strstr函数主要完成在一个字串中寻找另外一个字串 函数实现工程如下:摘自http://baike.baidu.com/link?url=RwrzOxs0w68j02J2uQs5u1A56bEN ...