>  기사  >  백엔드 개발  >  php中设置内存的方法介绍

php中设置内存的方法介绍

WBOY
WBOY원래의
2016-07-25 08:59:011466검색
  1. query_cache_size=32M

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

  3. # increases the number of file descriptors that mysqld requires.
  4. # Therefore you have to make sure to set the amount of open files
  5. # allowed to at least 4096 in the variable "open-files-limit" in
  6. # section [mysqld_safe]
  7. table_cache=256
  8. # Maximum size for internal (in-memory) temporary tables. If a table

  9. # grows larger than this value, it is automatically converted to disk
  10. # based table This limitation is for a single table. There can be many
  11. # of them.
  12. 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,或者上更高配置机器吧。



성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.