WordPressのメモリ制限を増やす方法

WordPress_Wpmet のメモリ制限を増やす方法

If you’re facing the WordPress error “Allowed Memory Size Exhausted”, the fastest solution is to increase the WordPress memory limit by updating your wp-config.php, php.ini, .htaccess file or by requesting a higher limit from your hosting provider.

In most cases, setting the WordPress PHP memory limit to 128MB or 256MB immediately resolves fatal errors, improves stability, and restores normal site performance, especially on hypermedia-heavy websites.

In this article, we’ll guide you on how to increase the WordPress PHP memory limit to correct memory exhaustion error in five methods. So, let’s dive into all these methods one by one after exploring the basics of WordPress memory limit.

Quick Overview

To resolve WordPress “Allowed Memory Size Exhausted” error, the fastest solution is to increase the WordPress memory limit by updating your wp-config.php, php.ini, .htaccess file or by requesting a higher limit from your hosting provider.

Here are the methods of how to increase WordPress memory limit in short:
Method 1: Increase WordPress memory limit via wp-config.php

  • Edit the wp-config.php file and increase the value of WP_MEMORY_LIMIT from 64M to 128M or 256M. This is the most reliable and beginner-friendly method.

Method 2: Increase PHP memory limit using php.ini

  • If the issue persists, update the PHP memory limit in the php.ini file by setting memory_limit = 256M or higher.
  • Restart the server after saving changes.

Method 3: Modify the .htaccess file

  • When php.ini access is restricted, add memory limit rules to the .htaccess file to increase PHP memory allocation at the server level.

Method 4: Use a WordPress memory extend plugin

  • Install a memory extend plugin such as WPMemory and WP Tools to increase the WordPress memory limit without editing core files. This method is ideal for beginners and non-developers.

Method 5: Contact your hosting provider or upgrade hosting

  • If none of the above methods work, your hosting plan may be enforcing strict limits. Request a higher memory allocation or upgrade your hosting plan to unlock better performance and scalability.

What is WordPress memory limit?

WordPress memory limit is the maximum amount of server memory (RAM) that a WordPress site is allowed to use while executing PHP scripts.

Why WordPress memory limit matters for your site performance?

The WordPress memory limit directly impacts how efficiently your site handles PHP processes, plugins, and dynamic content. When the memory allocation is too low, WordPress struggles to execute essential tasks.

Learn more why memory limit matters for your site performance:

  • Smooth operation: It ensures WordPress has enough PHP memory to run complex operations without interruption.
  • Minimizes errors: It Reduces the risk of critical errors such as “Allowed memory size exhausted”.
  • Heavy tool support: It supports heavy plugins and builders that demand more memory.
  • Loading time: Memory limit reduces slowdown while high traffic or complex request (e,g. backups, imports).
  • Sudden failure: this keeps theme and plugin features fully functional without unexpected failures.
  • Consistent site performance: It improves consistency of site performance across different environments.

WordPress で PHP のメモリ制限と最大アップロード制限を増やす方法:

How to Increase PHP WordPress Memory Limit to prevent memory exhaust error

There are five options you can use to resolve WordPress Memory Exhausted Errors and raise the memory capacity and upload limit in WordPress.
Let’s have a look in detail on how to increase the PHP memory limit in WordPress! 😃

注記: Always keep a new サイトのファイルとデータベースのバックアップ 重大な変更を加える前に、間違いを犯した場合にサイトを復元できるようにしてください。

1. Increase WordPress memory limit via wp-config.php

基本的な設定情報が含まれているため、wp-config.php メモリは WordPress Web サイトにとって不可欠なファイルの 1 つです。この WP config メモリ制限ファイルは、WordPress ファイル システムのルート ディレクトリにあります。

wp-config.php メモリ制限ファイルを編集して、PHP ファイルに割り当てられる WordPress メモリを増やします。
wp-config.php ファイル
  • Look for this line to edit the memory and upload limits on the wp-config.php memory limit file. Here is the WordPress minimum memory limit:
  定義('WP_MEMORY_LIMIT', '64M');
  • 変化 the value to a higher limit, such as ‘128M’ or ‘256M’.
  • 保存 the WP config PHP memory limit file and check if the error is resolved.
  • Note that some hosting providers may limit the maximum WordPress memory you can allocate, so you might not be able to set it to an arbitrarily high value.
  定義('WP_MEMORY_LIMIT', '128M');

注記: You’re good to go with this WP config.php memory limit increase method. However, If you’re still having a fatal error, you might need to increase it again. But don’t go too far or サーバーがクラッシュするでしょう。または、ホストに助けを求めることもできます。

2. Edit your PHP.ini file to increase WP memory limit

If changing the wp-config.php file doesn’t solve the problem, you’ll have to deal with the problem in your server settings. WordPress’s PHP memory limit increase method may work here.

共有ホスティングを使用している場合は、PHP.ini ファイルにアクセスできません。 PHP.ini にアクセスできる場合。ほとんどの場合、ルート フォルダーにありますが、ファイルの場所はホストによって異なります。 

行う必要があるのは次のとおりです。

  • Locate or find your php.ini file. If you can’t find it, simply build your php.ini file そして 保存 it in the WordPress installation’s root directory.
  • 使用 your favorite editor to open and 編集 your php.ini file.
  • Look for the line that says ‘memory limit = 32M’.
  • 変化 the 32M or some other number to the desired limit (e.g. 256M or 512M).
  • Restart your local host or server after saving your changes.

注記: 独自の php.ini ファイルを作成した場合は、次の行をそれに追加する必要があります。

メモリ制限 = 256M (または512M)

場合によっては、リストの 1 行目から 3 行目に進むにつれて、追加する値が大きくなることがあります。の 「メモリ制限」 が最大である必要がありますが、 「アップロード最大ファイルサイズ」 最低になるはずです。そしてその 'ポスト最大サイズ' 中央値である必要があります。

Clear your browser’s cookies before checking if the WordPress memory limit error has disappeared.

3. Edit your .htaccess file

If you don’t have access to PHP.ini, you’ll have to take the following attempts:

  • 編集 your WordPress .htaccess memory limit file as a last resort. Since it is a secret file, the .htaccess file begins with a mark.
  • チェック to see if your SFTP file manager is keeping some files hidden from view if you don’t see them in your root folder.
  • Here are the details you need to add to your .htaccess file to increase the WordPress memory limit:
php_valuememory_limit 256M php_valueupload_max_filesize 12M php_value post_max_size 13M
  • Increase the WordPress PHP memory capacity if it hasn’t already been set. You can 次のコードを使用してください to increase the PHP WordPress memory limit:
ini_set('memory_limit', '512M');ただし、それが書き込まれるファイルに対してのみ機能します。

4. Use the memory extend plugin

Other than editing wp-config.php, PHP.ini, and .htaccess files, you can extend the limit by utilizing the WordPress PHP memory limit increase plugin. There are numerous memory extend plugins such as WPメモリ, WPツールなど。これら WordPress メモリ制限プラグイン let you improve limits without touching your memory limit files. It is a friendly process for beginners and non-coders. So, try to optimize the memory limit by adopting a memory extend plugin if you want to avoid coding hassle.

5. Through the hosting provider

Contacting your hosting provider to increase your memory limit is the easiest among all methods. Most of the popular hosting providers include this service. However, their services may vary depending on the type of package you’re using. Also, some might not include this option. In this case, you need to adopt any one of the four methods mentioned above to enhance the memory capacity of your WordPress site.

6. Upgrade hosting service:

Upgrading your hosting plan becomes essential when your WordPress site starts demanding more server resources than your current hosting environment can provide. A higher-tier hosting plan offers increased PHP memory limits, better resource allocation, and improved scalability which ensures your site runs smoothly without constant technical interupption.

You should upgrade your hosting plan when:

  • You frequently encounter memory exhausted or fatal errors despite increasing the WordPress memory limit.
  • Your site has outgrown shared hosting limitations.
  • You are running WooCommerce, page builders, or multiple resource-intensive プラグイン。
  • High traffic causes slow loading times or server timeouts.
  • Site operations like backups, imports, or updates fail or take too long.
  • You need better performance, reliability, and room for future growth.

How to Fix Memory Limit While Migrating to a Live Server?

As PHP is a server-side プログラミング言語, and WordPress is written in it. For PHP to work properly, every website needs a hosting server.

So, when you move a local WordPress site to a live server, it’s quite common to run into PHP memory limit errors. This usually happens because your local machine has more flexible resources, while most hosting environments (especially shared hosting) set strict limits to keep things under control.

Here’s a breakdown of why this happens and how to fix it:

1. Increase PHP memory limit in wp-config.php:

  • You can increase the WordPress memory limit by adding a line to your wp-config.php ファイル。
  • The ‘256M’ (256 mega bites) here is the PHP memory limit. You can replace this to a higher value like ‘512M’ to increase the memory limit.

2. Update php.in file:

If updating your wp-config.php file doesn’t fix the issue, it could be that your server’s global PHP memory limit is set lower. In that case, you will need to:

  • を調整します。 php.ini file if you have the edit access to it.
  • The location of this file can vary depending on your hosting setup. Find it inside your hosting control panel (like cPanel).
  • If you can’t locate it, your hosting provider can point you in the right direction.
  • Once you’ve opened the file, search for the following line that says memory_limit and increase the value to a higher limit.

Before:

後:

3. Edit .htaccess File

Some hosting providers (mostly Apache servers) let you to override PHP settings right from the .htaccess file in your WordPress root folder. 

  • Add this line to edit .htaccess file:

WordPress にはどれくらいのメモリが必要ですか?

WordPress のメモリ要件は、Web サイトのサイズと複雑さ、使用するプラグインとテーマの数、サイトが受け取るトラフィックの量などのいくつかの要因によって異なります。したがって、WordPress に必要なメモリ量を答えるのはそれほど簡単ではありません。

WordPress 自体には 64 MB の最小メモリ要件がありますが、これは通常、ほとんどの Web サイトにとって十分ではありません。推奨最小値は約 128MB ですが、多くのホスティング プロバイダーは最適なパフォーマンスを得るために 256MB 以上を割り当てることを推奨しています。

基本的な機能を備え、トラフィックレベルが低い小規模な Web サイトの場合は、256 MB のメモリで十分です。ただし、Web サイトが成長し、プラグインやテーマが追加され、トラフィックが増加すると、より多くのメモリを割り当てる必要が生じる場合があります。

It’s worth noting that memory requirements can also vary depending on the hosting environment. Shared hosting plans may have stricter memory limitations compared to dedicated or cloud hosting solutions, such as キンスタ.

WordPress Web サイトの正確なメモリ要件を判断するには、ホスティングプロバイダーまたは WordPress プラグインが提供するツールを使用してサイトのメモリ使用量を監視できます。これらのツールは、サイトのメモリが不足しているかどうか、追加のリソースを割り当てる必要があるかどうかを特定するのに役立ちます。

ホスティング プロバイダーまたはシステム管理者に相談して、最適なメモリ割り当てを決定することを常にお勧めします。 特定の WordPress インストール、Webサイトの要件とホスティング環境に基づいてガイダンスを提供できるためです。

WordPress のメモリ枯渇エラーとは何ですか?

さらに詳しい情報については、ビデオをご覧ください。 致命的なエラーの解決策 下に:

Web サーバーは他のデバイスと同じように動作します。複数のアプリケーションを同時に効果的に実行するにはメモリが必要です。 WP のプログラムごとに、サーバー管理者によって異なる量のメモリ制限が割り当てられます。

WordPress を実行すると、テーマやプラグインの処理、PHP スクリプトの実行など、さまざまなタスクを処理するために一定量のメモリ (RAM) が必要になります。デフォルトでは、WordPress は使用できるメモリ量に制限を設定します。 Web サイトがこの制限を超えると、「メモリが枯渇したエラー」が発生します。

致命的な誤り: WordPress allowed memory size of 67108864 bytes exhausted (tried to allocate 2348617 bytes) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx

または

致命的な誤り: 許可されたメモリ サイズ 41943040 バイトを使い果たしました 致命的なエラー 許可されたメモリ サイズ WordPress

このエラー メッセージは、WordPress コードにデフォルトの割り当てメモリ制限よりも多くのメモリ制限が必要な場合に表示されます。

WordPress の「使い果たされたバイト数の許容メモリサイズ」とは何ですか

WordPress のエラー メッセージ「許容メモリ サイズのバイト数が使い果たされました」は、WordPress サイトが割り当てられたメモリ制限を超えたことを示します。各 WordPress サイトには、スクリプトの実行中に PHP が使用できるメモリ量を制限する事前定義されたメモリ制限があります。

When a script, such as a plugin or a theme, tries to allocate more memory than the WordPress allowed memory size or limit, this error occurs. The error message usually includes the specific memory size that has been exhausted.

たとえば、エラー メッセージは次のようになります。

 致命的な誤り: /path/to/wordpress/wp-includes/some-file.php の 123 行目で、許容メモリ サイズ 67108864 バイトが使い果たされました (123456 バイトを割り当てようとしました)。

WordPress PHP のメモリ制限はどれくらいですか?

PHPというのは、 サーバーサイドプログラミング言語 Web サイトの HTML ページを作成します。 

PHP は、WordPress の問い合わせを処理したり、計算を実行したりできる多用途の動的プログラミング言語ですが、そのためにはメモリが必要です。

WordPress’s default defined memory limit is 32MB, しかし、必要に応じて上げるのは普通のことです。たとえば、WooCommerce では WordPress のメモリ制限を次のように推奨しています。 64MB.

40MBに設定されているWordPress PHPメモリ制限を増やす方法
WordPress の最小メモリ

WordPress はデフォルトのメモリ制限に達すると、メモリ制限を上限まで引き上げようとします。 単一サイトのインストールの場合は 40MB そして マルチサイト インストールの場合は 64MB。それでも十分でない場合は、致命的なエラー メッセージ行が表示されます。

より多くのメモリを必要とするプラグインをインストールしていない限り、メモリ制限は 128MB ほとんどのページにはこれで十分です。をインストールします サーバーIPとメモリ使用量の表示 プラグインを使用して、各プラグインが消費するメモリ量を確認します。

プラグインを非アクティブ化すると、プラグインをアクティブ化した後にプラグインがメモリ使用にどのような影響を与えるかを確認できます。 サーバーIPとメモリ使用量の表示 プラグイン。サーバーの過負荷を避けるために、高品質、 オールインワンのプラグイン メモリを効率的に利用できます。

そもそも、なぜ WordPress はより多くのメモリ制限を要求するのでしょうか?

メモリ制限を増やすには、WordPress wp-config.php メモリ制限ファイルの最大アップロード サイズを増やす必要があります。 

ただし、注意しなければならない問題があります。メモリ制限を増やすと、WordPress の非効率性を特定するのが難しくなります。

WordPress のメモリ制限を増やす前に、次のことをお勧めします。 まず、何がより多くのメモリを消費しているのかを調べてください。問題に対処するために投入されるリソースが増えると、特にホストをアップグレードする計画がある場合、長期的にはコストが大幅に増加する可能性があります。

WordPress が非効率であると、サイトの動作が遅くなり、ユーザー エクスペリエンスが低下する可能性があります。ただし、解決策を得るには、問題の根本を特定する必要があります。これは、将来のさまざまな問題の解決に役立ちます。

ただ 4.4%の WordPress ウェブサイト 最新バージョンの PHP を使用してください、 そして 64% は古いバージョンを使用します アクティブな更新を受信しなくなります。

ホスティング サーバーの PHP を最新バージョンにアップグレードすると、WordPress の効率が向上し、WordPress のメモリ容量を増やす必要がなくなります。

WordPress の最大アップロード制限は何ですか? 

WordPress の最大アップロード制限とは、WordPress がアップロードできる最大ファイル サイズを指します。 WordPressの最大アップロード容量 メディア ライブラリのアップロード画面で見つけることができます

これはホストにとって有益ですが、サイトの効率も向上します。たとえば、大きな画像ファイルのアップロードは、ダウンロードと表示に時間がかかるため、Web 上でのパフォーマンスが低下します。

🤷‍♀️ 以下の点に留意してください。
この問題にさらにお金を費やして WP のメモリ制限を引き上げる前に、メモリ制限の場合と同じように、まずファイル サイズを減らすために何かできることがないかどうかを確認してください。

画像がコンテナに対して少し大きすぎる場合、または画像を圧縮していない場合は、アセットを適切に拡張していない問題の根本に対処するため、最初にそれらの問題を解決できます。詳細については、「 ウェブサイトを高速化する方法に関するガイド.

よくある質問

Does WordPress memory limit effect performance?

Yes. A low WordPress memory limit slows down PHP execution, causes fatal errors, and prevents plugins and themes from running smoothly that directly impact site performance.

Is 256M enough?

For most WordPress sites, 256M is sufficient. However, hypermedia-heavy sites, WooCommerce stores, or sites using advanced page builders may require more memory.

How to check current WordPress memory limit?

You can check the WP memory limit from wp-config.php file. In this file, you will find a line similar ( ‘WP_MEMORY_LIMIT’ , ‘128MB’ ). This means your WordPress memory limit is 128MB that you can further change by editing your WordPress PHP or other files.

WP_memory_limit と WP_max_memory_limit の違いは何ですか?

WP_memory_limit はフロントエンドのメモリ制限を示します。一方、WP_max_memory_limit は、バックエンド開発に割り当てられる PHP メモリ制限を指します。

What does Memory_limit=-1 mean in PHP?

Memory_limit= -1 は、不適切に書かれた PHP スクリプトによるすべてのメモリの使用を避けるために設定されます。これは、PHP スクリプトが過剰なサーバー リソースを使用してパフォーマンスの問題を引き起こすことが許可されていないことを意味します。

まとめ

サーバーを設定し、WordPress Web サイトのメモリ制限を増やすという致命的なエラーに対処するのは、神経をすり減らす作業です。従う必要がある手順は、選択したホスティング会社によって大きく異なります。そのため、信頼できるホストを入手することが非常に重要です。これらは、PHP WordPress のメモリ制限を増やすために変更する必要がある設定を見つけて変更するのに役立ちます。

ただし、wp メモリ制限を増やすと、 wp-config メモリ制限ファイルを使用して Web サイトにアクセスするのが最も簡単な方法です。, 他の 2 つは少し先になるかもしれません。 


コメント

  1. hirendraのアバター

    WordPress の最大アップロード制限は何ですか?

    1. Sanjidaのアバター
      サンジダ

      こんにちは、ヒレンドラさん

      お元気でお過ごしでしょうか。
      さて、WordPress の最大アップロード制限は 2MB から無限までです。

      プラグインと訪問者の数が限られている小規模な Web サイトでは、この制限で十分な場合があります。

      本当にありがとうございます💖

  2. Gayathri Reprographicsのアバター
    ガヤスリの複製

    ありがとう

  3. Eileen Valdezのアバター
    アイリーン・ヴァルディーズ

    こんにちは、
    WP メモリ制限を増やす方法に関する素晴らしい投稿を共有していただきありがとうございます。

    ありがとう

  4. Mohit Bhargavのアバター
    モヒト・バルガフ

    こんにちは

    wp-config ファイル経由で制限を 256m に設定しました。大丈夫ですか?

    ところで、この貴重な情報をありがとう。

    1. Sanjidaのアバター
      サンジダ

      いつでもモヒット!
      楽しい休日を…😄

      Wpmetチーム。

  5. Creativiztのアバター
    クリエイティブビズト

    これは、WordPress ブログの問題を解決するのに確実に役立ちます。共有してくれてありがとう!

  6. WordPress Expertsのアバター
    WordPress Experts

    The article glosses over important details. What if my host doesn’t allow changes to the php.ini file? Any alternatives?

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です