Home Backend Development PHP Tutorial Fatal error: Out of memory (allocated 262144) (tried to allocate 10267220 bytes)解决方案

Fatal error: Out of memory (allocated 262144) (tried to allocate 10267220 bytes)解决方案

Jun 13, 2016 pm 01:45 PM
ini limit memory set

Fatal error: Out of memory (allocated 262144) (tried to allocate 10267220 bytes)
请问这个怎么办?

我在程序前面加一个代码
ini_set('memory_limit', '50M');

要怎样才能运行起来呢?
用的是虚拟主机,

------解决方案--------------------
这个不能这样设置的吧?或者有限制。最好是php.ini里去改,然后重启apache。
不知道ini_set里修改后,是否立即生效。有点悬。
------解决方案--------------------
你可以写段代码测试下的,,应该是可以的……ini_set没有被禁吧

看看是否报内存超出限制

ini_set('memory_limit', '1M');
for($i=0;$i{
$arr[] = $i;
}
------解决方案--------------------
1048576 bytes = 1024K = 1 M

说明设置有效果

1M只是方便测试
------解决方案--------------------
可以立即生效
echo ini_get('memory_limit');//原值
ini_set('memory_limit', '50M');
echo ini_get('memory_limit');//现值

但问题不在这里
Out of memory (allocated 262144) (tried to allocate 10267220 bytes)
是说你在 262144 字节可用内存中
试图申请 10267220 字节空间
这显然是不能够的

memory_limit 表示的是允许php使用的最大空间,并不是一定有 memory_limit 的内存供你使用

你的情况表示内存碎片太多
重启 web 服务应该可以缓解
如频繁发生,就需要考虑安装内存管理软件,或增加内存条了

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of the Set tag function in MyBatis dynamic SQL tags Detailed explanation of the Set tag function in MyBatis dynamic SQL tags Feb 26, 2024 pm 07:48 PM

Interpretation of MyBatis dynamic SQL tags: Detailed explanation of Set tag usage MyBatis is an excellent persistence layer framework. It provides a wealth of dynamic SQL tags and can flexibly construct database operation statements. Among them, the Set tag is used to generate the SET clause in the UPDATE statement, which is very commonly used in update operations. This article will explain in detail the usage of the Set tag in MyBatis and demonstrate its functionality through specific code examples. What is Set tag Set tag is used in MyBati

CAMM2 for desktop PCs: MSI explains the benefits of the new RAM standard for gaming towers CAMM2 for desktop PCs: MSI explains the benefits of the new RAM standard for gaming towers Aug 17, 2024 pm 06:47 PM

The first LPCAMM2 modules for laptops are already being delivered, and desktop mainboards are also expected to be equipped with CAMM2 in future. CAMM2 and LPCAMM2 are not compatible with each other, and even on desktop PCs, customers need to be caref

Detailed explanation of how to use take and limit in Laravel Detailed explanation of how to use take and limit in Laravel Mar 10, 2024 pm 05:51 PM

"Detailed explanation of how to use take and limit in Laravel" In Laravel, take and limit are two commonly used methods, used to limit the number of records returned in database queries. Although their functions are similar, there are some subtle differences in specific usage scenarios. This article will analyze the usage of these two methods in detail and provide specific code examples. 1. Take method In Laravel, the take method is used to limit the number of records returned, usually combined with the orderBy method.

How to delete elements from set in javascript How to delete elements from set in javascript Jan 12, 2022 am 10:56 AM

Methods to delete elements: 1. Use delete() to delete the specified element from the Set object, the syntax is "setObj.delete(value);"; 2. Use clear() to delete all elements in the Set object, the syntax is "setObj.delete(value);" "setObj.clear();".

MySQL storage engine selection comparison: InnoDB, MyISAM and Memory performance index evaluation MySQL storage engine selection comparison: InnoDB, MyISAM and Memory performance index evaluation Jul 26, 2023 am 11:25 AM

MySQL storage engine selection comparison: InnoDB, MyISAM and Memory performance index evaluation Introduction: In the MySQL database, the choice of storage engine plays a vital role in system performance and data integrity. MySQL provides a variety of storage engines, the most commonly used engines include InnoDB, MyISAM and Memory. This article will evaluate the performance indicators of these three storage engines and compare them through code examples. 1. InnoDB engine InnoDB is My

Blue screen problem caused by win10 memory management Blue screen problem caused by win10 memory management Dec 30, 2023 pm 07:11 PM

The win10 system is an excellent system that is worth using. Its strong compatibility and high intelligence can ensure that there will be basically no problems in the use of the win10 system. However, recently, many friends have reported that their computers frequently have blue disks. And it always prompts the error code memorymanagement. What's going on? Today, the editor will bring you the solution to the frequent blue screen of win10 and the memory management termination code. If you need a game, come and take a look. Solution to win10memorymanagement blue screen: Solution 1: 1. Use "Win key + R" + enter "control + enter" to enter the control surface

Solution to PHP Fatal error: Allowed memory size of bytes exhausted Solution to PHP Fatal error: Allowed memory size of bytes exhausted Jun 22, 2023 am 08:13 AM

PHP is a widely used server-side scripting language, but when running PHP applications, you may encounter the error message 'PHPFatalerror: Allowedmemorysizeofbytesexhausted', which usually means memory allocation problems. In this article, we will explore some common causes of ‘PHPFatalerror:Allowedmemorysizeofbytese

Comparison of functions and usage of take and limit in Laravel Comparison of functions and usage of take and limit in Laravel Mar 09, 2024 pm 09:09 PM

Take and limit are two commonly used methods in Laravel to limit the number of query result sets. Although they have certain similarities in functionality, they differ in usage and some details. This article will conduct a detailed comparison of the functions and usage of the two methods, and provide specific code examples to help readers better understand the differences between them and how to apply them correctly. 1.take method The take method is in the LaravelEloquent query builder

See all articles