Home > Backend Development > PHP Tutorial > Introduction to how to set memory in php

Introduction to how to set memory in php

WBOY
Release: 2016-07-25 08:59:01
Original
1526 people have browsed it
  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

Copy code

In addition, let’s introduce the method of setting the runtime memory size in PHP.

If the following error occurs when the php program is running: Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 7325604 bytes) in … (The available memory is 20971520 bytes, try to allocate...) It means that the memory allocated during runtime is not enough. At this time, it is necessary to increase the memory to support PHP operation.

Solution: 1. Dynamically allocate memory in php program

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

2. Configuration in php.ini

memory_limit = 20M //Modify 20M

That’s all. I remember my boss once said, I believe in your technical level. If you encounter a problem that is very difficult to solve, just give full play to the advantages of the hardware. Haha, then add more memory, more CPU, or more. A higher configuration machine.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template