php 内存设置1g,php中设置内存的方法介绍

首先,推荐如下的设置php内存的方法:

1,在php.ini文件中设置memory_limit = 12M(推荐)

2,在sites/default/settings.php文件里设置ini_set('memory_limit','12M');

3,在.htaccess文件中设置php_value memory_limit 12M

以下两个方法,可以修改php运行时的内存限制。

在php.ini文件里设置memory_limit = 12M(推荐)

在sites/default/settings.php文件里设置ini_set('memory_limit','12M');

例如:

复制代码 代码示例:

query_cache_size=32M

# The number of open tables for all threads. Increasing this value

# increases the number of file descriptors that mysqld requires.

# Therefore you have to make sure to set the amount of open files

# allowed to at least 4096 in the variable "open-files-limit" in

# section [mysqld_safe]

table_cache=256

# Maximum size for internal (in-memory) temporary tables. If a table

# grows larger than this value, it is automatically converted to disk

# based table This limitation is for a single table. There can be many

# of them.

tmp_table_size=5M

另外,再介绍下PHP设置运行时内存大小的方法。

如果在php程序运行时出现如下的错误:

Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 7325604 bytes) in …(可用的内存为20971520 bytes,尝试分配。。。)则说明运行时分配的内存不够,此时需要增加支撑php运行的内存了。

解决办法:

一、在php程序里动态分配内存

@ini_set(‘memory_limit’,’60M‘);  //修改60M

二、php.ini 中配置

memory_limit = 20M //修改 20M

就介绍这些了,记得老板曾说过一句话,我相信你们的技术水平,如果遇到非常难以解决的问题,就适当发挥硬件的优势吧,哈哈,那就加内存,加Cpu,或者上更高配置机器吧。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值