Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

修正: WordPressのメモリ不足エラー – PHPのメモリを増やす

WordPressで許容メモリサイズ不足のエラーメッセージが表示されますか?

これはWordPressで最もよく見られるエラーのひとつで、WordPressのPHPメモリ制限を増やすことで簡単に解決できます。

この投稿では、PHPのメモリ制限を増やすことによってWordPressのメモリを使い果たしたエラーを修正する方法を紹介します。

Fix: WordPress Memory Exhausted Error – Increase PHP Memory

WordPress Memory Exhausted Errorとは?

WordPressのメモリを使い果たしたエラーは、あなたのサイトがタスクを実行するのに苦労している場合に表示される可能性のあるメッセージです。

WordPressはサーバーサイドのプログラミング言語であるPHPを使ってビルトインされており、実行にはメモリが必要です。

他のコンピューターと同じように、ウェブサーバーも複数のアプリケーションを同時に実行するためのメモリ量には限りがあります。WordPressホスティングサービスプロバイダーは、PHPを含むさまざまなアプリケーションに特定のメモリサイズを割り当てます。

WordPressコードが初期設定より多くのメモリを必須とする場合、このエラーメッセージが表示されます:

致命的なエラー:許容メモリサイズ 33554432 バイトを使い果たしました(2348617 バイトを割り当てようとしました) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx

Memory exhausted error displayed on a WordPress site

WordPressサイトがサーバーメモリを使い果たしている可能性があります:

  • 画像、動画、その他のメディアの数々
  • 未使用のWordPressプラグインが豊富
  • ホスティングプランのリソースを使い果たした

初期設定では、WordPressはPHPのメモリ制限が64MB未満の場合、自動的に増やそうとします。しかし、64MBでは十分でないことがよくあります。

とはいえ、WordPressのPHPメモリ制限を簡単に増やして、メモリ不足エラーを回避する方法を見てみよう。

チュートリアルのナビゲーションには、以下のクイックリンクをご利用ください:

注: これらの方法の中には、WordPressファイルを直接編集する必要があるものもあります。エラーの発生を防ぐため、まずサイトをバックアップすることをお勧めします。

設定1:wp-config.phpファイルの編集

まず、WordPressサイトのwp-config.phpファイルを編集する必要があります。これは、ルート・ディレクトリにあるWordPressのコア・ファイルのひとつで、通常はpublic_htmlという名前になっています。

FileZillaのようなFTPクライアント、またはウェブホスティングサービスコントロールパネルのファイルマネージャを使用する必要があります。

次に、次の行をwp-config.phpファイルの「すべてです、編集を中止してください」という行の直前に貼り付ける必要があります!それでは、よいブログを。

define( 'WP_MEMORY_LIMIT', '256M' );

このコードはWordPressにPHPのメモリ制限を256MBに増やすように指示します。

詳しくは、wp-config.phpファイルの見つけ方と編集方法のステップバイステップガイドをご覧ください。

完了したら、変更を保存し、wp-config.phpファイルをサーバーにアップロードする必要があります。

これでWordPressサイトにアクセスできるようになり、メモリ枯渇エラーは消えているはずです。

設定2:.htaccessファイルの編集

次の方法は、.htaccessファイルを編集することです。このファイルもWordPressサイトのルート・フォルダーにあります。

ここで、#END WORDPRESSと書かれた行の前に以下のコードを貼り付ける必要があります。

php_value memory_limit 256M

前のコードと同様に、WordPressにPHPのメモリ制限を256MBに増やすように指示します。

その後、変更を保存し、ファイルをWebサーバーにアップロードしてください。これで、WordPressサイトをもう一度開いて、メモリ制限エラーがなくなっているかどうかを確認することができます。

.htaccessファイルが見つからない場合は、.htaccessファイルが見つからない理由と見つける方法についてのガイドをご覧ください。

設定3:php.iniファイルをチェックする

上記の方法でうまくいかない場合は、php.iniファイルを見てください。

php.iniは、PHPのバージョンやPHPスクリプトなど、PHPの設定をコントロールするファイルです。通常はホスティングサービスが管理しているため、WordPressのコアファイルではありません。

PHPのメモリ使用量の上限を確認するには、そのコードをチェックすることができます。詳しくは、php.iniファイルの見つけ方と編集方法をご覧ください。

しかし、これは高度な方法なので、代わりにホスティングサービスのサポートチームに連絡して、WordPressのメモリ制限を手動で増やせるかどうか確認することをお勧めします。そうしないと、さらなるエラーが発生する可能性があります。

詳しくは、WordPressサポートの正しい依頼方法をご覧ください。

オプション4:WordPressホスティングサービスのアップグレード状況

定数メモリ枯渇エラーに遭遇している場合、それはあなたのサイトが現在のホスティングプランを使い果たしたサインかもしれません。

サイトへの訪問者が増え、コンテンツが追加されるにつれ、円滑に機能するためにはより多くのリソースが必須となります。メモリ割り当ての多いプランにアップグレードすれば、恒久的な解決策となります。

以下の場合は、WordPressホスティングサービスのアップグレードをご検討ください:

  • これまでの解決策を試しても、エラーが消えない。
  • あなたのサイトのトラフィックやコンテンツが大幅に増加しました。
  • より多くのリソースを必須とする機能や特徴の追加を計画している。

Bluehostは、あなたのサイトのニーズに応じて拡張することができ、手頃な価格と信頼性の高いWordPressホスティングサービスプランを提供しています。彼らは特にWordPressに最適化されたユーザーフレンドリーなプラットフォームを提供し、それはあなたのサイトを管理することが容易になります。

あなたは私たちのBluehostのクーポンコードを使用する場合は、最初の購入の61%オフまで得ることができます。ちょうどそれを得るために下のボタンをクリックします:

Bluehost offer for WPBeginner readers

WordPressのメモリを使い果たさない方法

WordPressのメモリを使い果たしたエラーを修正した後は、再発を防ぐための予防策をご紹介します:

この投稿が、PHPのメモリ制限を増やすことでWordPressのメモリを使い果たしたエラーを解決するのにお役に立てば幸いです。WordPressエラーのトラブルシューティングのステップバイステップのビギナーズガイドや、サイトを成長させる最高のWordPressプラグインのエキスパートピックもご覧ください。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

アバター

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

464件のコメント返信を残す

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Adam says

    Thanks for this article, we’ve been having this problem too.

    Which setting takes priority?
    In WHM (MultiPHP INI Editor), memory_limit is set to 32M.
    In wp-config.php WP_MEMORY_LIMIT is set to 96M.

  3. arjun says

    but what exactly is this wordpress memory limit, like how much amount of RAM should wp use on the server? can anyone please share about what this thing is?

    thanks

    • WPBeginner Support says

      The memory limit tells WordPress how large requests/files can be for individual tasks, this is not for your site’s RAM and your RAM usage would be determined by what is on your site.

      管理者

  4. fazan says

    thanks you wpbeginner
    you solve my problom
    but i have vps , can i increes more memory limit
    please reply

    • WPBeginner Support says

      You would need to reach out to your hosting provider for what is available to you

      管理者

  5. Ananth Gurunathan says

    Thanks for the post. It really worked out for me for my problem which was a big head ache for last 5days. Thanks a lot.

  6. Peter says

    There needs to be a way to figure out these memory issues without taking the entire site offline or risking breaking the configuration by disabling essential components. Furthermore, the errors are occurring even when the memory limit is set to the maximum physical memory on the server (32GB) and while they are occurring there is no actual spike in memory usage (system utilities are reporting no increase in actual physical memory use.

  7. Peter says

    Useless when the issue does not depend on actual required memory – in my case it keeps giving the error for random plugins no matter how much memory I specify (up to 32GB). Would be nice to know an actual troubleshooting method to see what is using the memory.

  8. Wim Hoogenraad says

    I wish I known that earlier. Now | lost a lot of traffic for my site.
    Hopefully it is fixed now!

  9. Mara says

    It works, thank you <3

    The error was:
    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 491520 bytes) in…

  10. EAT (my actual initials) says

    Thank you so, so, so, sooooooooooo, so much! I guess as I add more posts to the database it requires more memory to operate. Various things were breaking with this internal error over the course of a couple of years, but since I could still make new posts I just said to myself, “meh, carry on.”

    Then I could no longer post! Panic! Everybody PANIC!!!

    I enabled debug mode. I got my debug report. I saw the memory exhausted reported. Then I found this page and gave it a try, thinking, “This probably won’t work. I’ve made too many changes to the theme and some of the plugins to work the way I want. Something somewhere got MuNgEd.

    Nope. Not at all. This one line of code solved it and got be back up and RUNNING!!!! Yay for me!!!! YAY FOR YOU!!!!

  11. Mykola says

    And if you have same problem in admin page you can also try

    define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ );

    Administration tasks require much memory than usual operation. When in the administration area, the memory can be increased or decreased from the WP_MEMORY_LIMIT by defining WP_MAX_MEMORY_LIMIT.

    WP_MAX_MEMORY_LIMIT sets the maximum just on admin pages. It’s a terrible naming scheme but it dates back to WordPress 2.5 and nobody dares change it now

  12. Laura Mailleux says

    I have tried this, and now my entire admin panel and website are down, all blocked by that 500 error…. I cannot access anything anymore, and therefore can’t use the File Manager again to remove the change. I’m completely lost, any chance you can help me?

    • WPBeginner Support says

      Hi Laura,

      If you have access to cPanel dashboard then you can undo the changes from the file manager section there. Alternately, you can contact your hosting provider to help you fix this.

      管理者

  13. prashant says

    i have to use wpml plugin issue is english language text editor working properly but when i text german or spanish language (secndery languages ) text editor cant showing on secndery languages text editor so ghow to fix that problem

  14. Jonathan says

    Help! i have this problem :(

    Allowed memory size of 268435456 bytes exhausted (tried to allocate 10489856 bytes)

  15. Majid Korm says

    Thank you very much
    My issues got solved completely based on your detailed information and help.
    many many thanks
    Majid

  16. Jonny says

    I’m not as good at this stuff as I need to be, so I’m still struggling with this.

    I open the config.php file and there is a part that says:
    define( ‘WP_MEMORY_LIMIT’, ‘256M’ );

    only it already says:
    define(‘WP_MEMORY_LIMIT’, ‘1024M’);

    I’ve changed that to 2048 and 4096 with no change.

    But there is no ‘That’s all, stop editing! Happy blogging.’

    after the
    define(‘WP_MEMORY_LIMIT’, ‘1024M’);
    it says
    define(‘WP_DEBUG’, false);

    then
    # That’s It. Pencils down

    It does say ‘That’s all, stop editing! Happy blogging.’ in the Sample config.php but not in the actual one.

    Any advice?

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。