利用可能なメモリを増やして out of memory エラーを修正する方法

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

本ナレッジベースはアトラシアンの サーバー プラットフォーム向けに記載されたものです。Atlassian Cloud との機能の違いにより、本記事の内容を Atlassian Cloud アプリケーションに適用することはできません。

目的

Java applications like JIRA, Crowd and Confluence run in a "Java virtual machine" (JVM), instead of directly within an operating system. When started, the Java virtual machine is allocated a certain amount of memory, which it makes available to applications like Confluence. By default, Java virtual machines are allocated 64Mb of memory, no matter how many gigabytes of memory your server may actually have available. 64Mb is inadequate for most Confluence installations, and so this needs to be increased.

診断

ここをクリックして展開...

Determine type of error message

Look in the atlassian-confluence.log to see which type of OutOfMemory Error you're receiving. There are three common messages:

  1. Heap Space
  2. Perm Gen Space
  3. GC Overhead
tip/resting Created with Sketch.

This document discusses increasing memory to address PermGen and Heap space errors. Follow the links above to assess root causes for each issue.

For GC Overhead, refer to Confluence Crashes Due to 'java.lang.OutOfMemoryError GC overhead limit exceeded'.

Determine Confluence's usage patterns

In Confluence, go to Confluence Administration > System Information, and look at the memory graph during times of peak usage:

This server has been allocated a maximum of 650Mb and a minimum of 256m. You can see the minimum displayed here; if you're trying to see whether your settings are being picked up, this is where to look.

使用可能なシステムメモリの確認

Windows の場合

From the Close Programs Dialogue (Press ctrl-alt-delete), select the Performance tab:

The amount marked Available is the amount in kilobytes you have free to allocate to Confluence. On this server we should allocate at most 214Mb.

Linux の場合

Run

cat /proc/meminfo 

to view the memory usage.

サーバーで使用可能な容量を超えて -Xmx を設定すると、物理メモリ不足から OutOfMemoryErrors が発生する可能性があります。これが発生した場合、スワップ容量が使用され、パフォーマンスが大幅に低下します。

ガイダンス

The default values supplied with Confluence stand-alone are sufficient for most installations. Please refer to Managing Application Server Memory Settings and Server Hardware Requirements Guide for a discussion.

ソリューション

Step 1: Increase Available Memory

We aren't really able to give a concrete recommendation for the amount of memory to allocate, because that will depend greatly on your server setup, the size of your user base, and their behaviour. You will need to find a value that works for you, i.e. no noticeable GC pauses, and no OutOfMemory errors.

For reference, the 3 most common parameters used to change the memory (heap) allocation are:

  • Xms - the minimum size of the heap
  • Xmx - the maximum size of the heap
  • -XX:MaxPermSize - the maximum size of PermGen (this is not used in Java 8 and above)

    In case you need an advice regarding how much memory you should use please check this page for some examples of hardware specifications.

If you do decide to increase the memory settings, there are a few general guidelines to follow.

  • Increase Xmx in small increments (eg 512mb at a time), until you no longer experience the OutOfMemory error. This is because increasing the heap beyond the capabilities of your server to adequately Garbage Collect can cause other problems (eg performance/freezing)
  • If your error is java . lang . OutOfMemoryError : PermGen space, increase the -XX:MaxPermSize parameter in 256mb increments until the error stops occurring.

  • If your error does not reference PermGen, there is no need to increase it. In a simplistic explanation, PermGen is used to store classes, and is generally quite static in size, and has been removed in Java 8. More info here.
  • Consider setting Xms and Xmx to the same value, as this can decrease the time GC takes to occur, as it will not attempt to resize the heap down on each collection.

    tip/resting Created with Sketch.

    See our Garbage Collection (GC) Tuning Guide for more detailed information.

Linux


ここをクリックして展開...

To increase heap or perm gen space memory in Linux installations,

  1. Confluence をシャットダウンします。
  2. From <confluence-install>/bin (Stand-alone) or <Tomcat-home>/bin (EAR-WAR installation), open setenv.sh (you can create this file in the EAR/WAR version).
  3. Find the section
  • CATALINA_OPTS="-Xms1024m -Xmx1024m -XX:+UseG1GC $CATALINA_OPTS" in Confluence 5.8 or above
  • CATALINA_OPTS="$CATALINA_OPTS -Xms1024m -Xmx1024m -XX:MaxPermSize=256m -XX:+UseG1GC" in Confluence 5.6 or 5.7
  • JAVA_OPTS="-Xms256m -Xmx512m -XX:MaxPermSize=256m in previous versions
  1. See Diagnosis above and enter the appropriate values. Xmx is maximum, Xms is minimum, and MaxPermSize is PermGen.
  2. Confluence を起動します。


Windows (.batファイルから起動)


ここをクリックして展開...

If you start Confluence as a Service on Windows, then you should not use these instructions. Instead, refer to the "Windows Service" section below.

You should only follow these instructions if you are starting Confluence via the batch file. The batch file is not used when Confluence is started as a Service.

Windowsインストールで .bat ファイルから起動する際にシステム プロパティを設定する方法

  1. Confluence をシャットダウンします。
  2. From <confluence-install>/bin (Stand-alone) or <Tomcat-home>/bin (EAR-WAR installation), open setenv.bat.
  3. Find the section
    • CATALINA_OPTS="-Xms1024m -Xmx1024m -XX:+UseG1GC $CATALINA_OPTS" in Confluence 5.8 or above
    • CATALINA_OPTS="$CATALINA_OPTS -Xms1024m -Xmx1024m -XX:MaxPermSize=256m -XX:+UseG1GC" in Confluence 5.6 or 5.7
    • JAVA_OPTS="-Xms256m -Xmx512m -XX:MaxPermSize=256m in previous versions
  4. See Diagnosis above and enter the appropriate values. Xmx is maximum, Xms is minimum, and MaxPermSize is PermGen.
  5. Confluence を起動します。


Windows サービス


ここをクリックして展開...

There are two ways to configure system properties if you Start Confluence Automatically on Windows as a Service - either via command line or in the Windows Registry

Windows サービスのプロパティをコマンド ラインから設定する

Windows サービスのプロパティをコマンド ラインから設定する

  1. Identify the name of the service that Confluence is installed as in Windows ( Control Panel > Administrative Tools > Services ):

    (info) In the above example, the SERVICENAME is: JIRA030908110721 (this is a JIRA screenshot, but the same applies to Confluence)
  2. Start >> Run >> type in 'cmd' >> Enter でコマンド ウィンドウを開きます。
  3. cd to the bin directory of your Confluence instance, or the bin directory of your Tomcat installation if your are running Confluence EAR/WAR.
  4. Run (for tomcat8, change as necessary for earlier versions):

    tomcat8w //ES//<Your_Service_Name>
    

    .
    (info) If you are under confluence 5.5, it would be tomcat6w //ES//JIRA030908110721 instead of tomcat8w (this is a JIRA screenshot, but the same applies to Confluence)

  5. Click on the Java tab to see the list of current start-up options:
  6. ここで最大メモリ割り当てを設定します
  7. Also add -XX:MaxPermSize=512m to the java options section (if required). 

Windows レジストリで Windows サービスのプロパティを設定する

Windows の一部のバージョンには、Java 変数をサービスに追加するオプションがありません。この場合、レジストリ内のオプション一覧を表示してプロパティを追加する必要があります。

Windows サービスのプロパティを Windows レジストリで設定する方法

  1. Go to Start >> Run, and run "regedit32.exe"
  2. サービス エントリを見つけます:
    32 ビット: HKEY_LOCAL_MACHINE >> SOFTWARE >> Apache Software Foundation >> Procrun 2.0 >> Confluence
    64 ビット: HKEY_LOCAL_MACHINE >> SOFTWARE >> Wow6432Node >> Apache Software Foundation >> Procrun 2.0 >> Confluence
  3. 既存のプロパティを変更する (特に Xmx メモリを増やす) には、適切な値をダブルクリックします。
  4. To change additional properties, double-click options. Note: Make sure to add only one argument per line.
  5. Modify the memory allocations here (i.e. -XX:MaxPermSize=512m).


Step 2: Verify Your Settings

To verify what settings are in place, check Viewing System Information. You should see a section called "Java Runtime Arguments".

Xmx (最大) および Xms (最小) 設定を探します。


Alternatively, on Linux, run

ps -aux | grep java

to see the environment parameters.

最終更新日 2018 年 11 月 12 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.