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. Ifedayo says

    Thank you, this was helpful! All problem has been solved by carefully following this step-by-step instructions. Keep up the good work :)

  3. Doy says

    Hi,

    Thank you for this awesome website. I got this in the error log after adding this code.
    [26-Apr-2022 02:45:31 UTC] PHP Warning: Use of undefined constant ‘WP_MEMORY_LIMIT’ – assumed ‘‘WP_MEMORY_LIMIT’’ (this will throw an Error in a future version of PHP) in /wp-config.php on line x

    Is this a problem? Should I remove the code?

    • WPBeginner Support says

      That would only be an error for future versions of PHP. This solution should only be a temporary fix and your hosting provider should be able to assist with the root cause of the issue.

      管理者

  4. Alison Taylor says

    Thank you! You folks rock. This solved my problem. WPBeginner is my go-to website for learning new things about WordPress, even though I’m not a beginner.

  5. J h says

    “Once you are done, you need to save your changes and upload your wp-config.php file back to your server.”

    How again do you upload the file back to your server?

    • WPBeginner Support says

      You would need to use FTP or your host’s file manager again and there should be the option to upload and replace the file :)

      管理者

  6. Daniel says

    The changes are not having effects. We are still with 40MB and the site does not accept the changes. What should I do?

    • WPBeginner Support says

      As we state at the end of the article, if our recommendations do not work, please reach out to your hosting provider as they may have set a limit that would override what you as a user can set.

      管理者

  7. Liviu says

    Really worked.

    I had white screen when I wanted to create a new post on PC browser. But worked on my phone.

    Thanks

  8. John Harries says

    Thank you for providing a straight forward solution to an error which occurred when I tried to update the php version from 7.1 to 7.4

  9. Mart says

    Fantastic, thank you soooo much for this, simple straight talk.. excellent.. first problem solved … now got to learn more

    • WPBeginner Support says

      It can mean the site can take longer to notice issues if some arise but shouldn’t cause a major issue in general.

      管理者

  10. Mujahid Siyal says

    I added the code problem is gone but a text “WP_MEMORY_LIMIT” has appeared in the top corner of logo. So what should I do about that?

    • WPBeginner Support says

      You would want to ensure you added the code snippet correctly as it is likely showing that code thinking it is text.

      管理者

  11. David says

    “First you need to edit the wp-config.php file on your WordPress site. It is located in your WordPress site’s root folder, and you will need to use an FTP client or file manager in your web hosting control panel.”

    Simple! What does that mean? It is gobbledegook to me.

  12. Katerina says

    I’m new in WordPress and I’m trying to figure out, for a couple of days, why suddenly I get an error 500 and can’t save my edits. This helped solve my problem. Thank you so much!

  13. Arpita Hunka says

    This solution is not working for me, my website is hosted at AWS server and I have all the access, I have tried to set memory_limit in php.ini, wp-config and .htaccess. but still getting issue when accessing backend pages.

    • WPBeginner Support says

      You would want to reach out to the support for your hosting for what other options you have available with AWS

      管理者

  14. Benthe Kuijpers says

    Thanks so much! Was so worried when I had this fatal error, but this fix is just a piece of cake! :-)

    • WPBeginner Support says

      If our recommendations are not working, you would want to reach out to your hosting provider and they should be able to assist

      管理者

  15. Ivan says

    Hi, I had the memory exhausted message and I increased the wp memory limit to 12mb and it worked. Then a few days later I had the same error, so I had to increase the wp memory limit to 256mb and the message kept showing. I am currently on 1024mb, which seems excessive for a small website of 4 pages and a blog post of 15,000 words. Any suggestions how to resolve the issue or what might be causing it?

    • WPBeginner Support says

      You would want to reach out to your hosting provider and they can normally assist in finding the root of the issue for your specific site.

      管理者

  16. Gk Guru says

    My website has been hacked. Which is showing the homepage blank. In which the script has been injected, as well as the entire WordPress files. Database file is also affected.

    Please suggest any solution for this. What do i have to do next steps.

  17. Jayant singh rawat says

    Hey. My website is doing well. but whenever i tried to edit any post my server memory and I/O exhaust

    • WPBeginner Support says

      If you reach out to your hosting provider they should be able to help prevent this error going forward

      管理者

  18. Ricardo M says

    It worked!! thanks a lot, I should say that if you are using control panel you can access and edit the file config,php within the same platform no need to dowload the file for editing.

    • WPBeginner Support says

      It depends on the hosting provider as not all have a file manager that they offer but thanks for sharing :)

      管理者

返信を残す

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