Bitbucket Server crashes due to java.lang.OutOfMemoryError PermGen Space Error

お困りですか?

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

コミュニティに質問

If you're experiencing this issue after upgrading to Bitbucket Server 3.8+ and are using Java 7, it's likely that the setenv.sh (setenv.bat for Windows) was copied from a previous Bitbucket Server installation you used to have. If this is the case, a new version of the setenv.sh will need to be obtained from the version of Bitbucket Server that you're using and any customizations you have (such as setting the heap size) be manually made to the file. You can obtain the same file by downloading your Bitbucket Server release from our website.

症状

Bitbucket Server crashes. The following appears in the atlassian-bitbucket.log:

java.lang.OutOfMemoryError: PermGen space

原因

What does it generally mean?

The error message java.lang.OutOfMemoryError: PermGen space this means Java's fixed block for loading class files has been exceeded. Permanent Generation Memory, unlike Java heap space, is the memory allocation for the classes themselves as opposed to the objects created. The addition of more plugins contributes to more consumption of PermGen space and is usually the cause of this error. The error occurs when enough classes are invoked.


Why does it fail if I copy a setenv.sh from a previous version into the binaries shipped with Bitbucket Server 3.8+?

A little more context on the change that likely triggered this issue if the setenv.sh file was copied from an older version into <Bitbucket Server 3.8 installation directory>/bin is that, as of Bitbucket Server 3.8 we removed the permgen.sh script that checked if PermGen is supported (the suppport to PermGen been removed in Java 8).

The differences in the setenv.sh can be seen below:

setenv.sh Bitbucket Server 3.7
 JAVA_OPTS="-Xms${JVM_MINIMUM_MEMORY} -Xmx${JVM_MAXIMUM_MEMORY} ${JMX_OPTS} ${JAVA_OPTS} ${JVM_REQUIRED_ARGS} ${JVM_SUPPORT_RECOMMENDED_ARGS} ${BITBUCKET_HOME_MINUSD}"

# PermGen size needs to be increased if encountering OutOfMemoryError: PermGen problems. Specifying PermGen size is
# not valid on IBM JDKs
BITBUCKET_MAX_PERM_SIZE=256m
if [ -f "${PRGDIR}/permgen.sh" ]; then
    echo "Detecting JVM PermGen support..."
    . "${PRGDIR}/permgen.sh"
    if [ $JAVA_PERMGEN_SUPPORTED = "true" ]; then
        echo "PermGen switch is supported. Setting to ${BITBUCKET_MAX_PERM_SIZE}\n"
        JAVA_OPTS="-XX:MaxPermSize=${BITBUCKET_MAX_PERM_SIZE} ${JAVA_OPTS}"
    else
        echo "PermGen switch is NOT supported and will NOT be set automatically.\n"
    fi
fi
setenv.sh Bitbucket Server 3.8
JAVA_OPTS="-Xms${JVM_MINIMUM_MEMORY} -Xmx${JVM_MAXIMUM_MEMORY} ${JAVA_OPTS} ${JVM_REQUIRED_ARGS} ${JVM_SUPPORT_RECOMMENDED_ARGS} ${BITBUCKET_HOME_MINUSD}"

# PermGen size needs to be increased if encountering OutOfMemoryError: PermGen problems.
MAX_PERM_SIZE=256m
JAVA_OPTS="-XX:MaxPermSize=${MAX_PERM_SIZE} ${JAVA_OPTS}"

export JAVA_OPTS

From the scripts above, if setenv.sh was copied over from Bitbucket Server 3.7- to an environment running on Java 7, the test to check if using PermGen is allowed always returns false since permgen.sh is no longer shipped with Bitbucket Server 3.8+ and the PermGen size gets set to the default in Java 7, which is too small for Bitbucket Server and causes the Out of Memory Error.

ソリューション

What does it generally mean?

As a rule of thumb, the best course of action is to identify why the PermGen is being filled up.

You might want to try the following to adjust your PermGen.

How to resolve?

Bitbucket Server 5.0+ では setenv と環境変数に変更があります

Bitbucket Server 5.0 以降では setenv.shsetenv.bat が取り除かれています。これらのファイルで設定されていたオプションは、環境変数で設定できるようになりました。環境変数の設定場所は、実行先のオペレーティング システムに応じます。

Linux

When using the atlbitbucket service on Linux, the environment variables are ignored. You must set the parameters in _start-webapp.sh (or start-bitbucket.sh). These values will be read when the service starts.

たとえば、 JVM_SUPPORT_RECOMMENDED_ARGS を設定するには、ファイルに次の行を追加します。

JVM_SUPPORT_RECOMMENDED_ARGS=-XX:+HeapDumpOnOutOfMemoryError

Windows

Bitbucket Server を実行しているユーザーで、パラメーターを環境変数として設定します。たとえば、JVM_SUPPORT_RECOMMENDED_ARGS を設定したい場合、それを環境変数として作成して適切な値を割り当てます。Bitbucket Server がスタートアップ スクリプトやサービスを利用して起動する際に、この値が取得および適用されます。

Linux

Linux での手順を展開して確認

Edit <bitbucket-install>/bin/setenv.sh and modify the MAX_PERM_SIZE (or BITBUCKET_MAX_PERM_SIZE for Bitbucket Server 3.7-) value to be larger. It's recommended to increase by 128mb blocks, testing each increase. Setting a value too high can be just as problematic as one that is too low.

Windows サービス

Expand to see Windows Service instructions
  1. Identify the name of the service that Bitbucket Server is installed as in Windows ( Control Panel > Administrative Tools > Services ):
  2. Start >> Run >> type in 'cmd' >> Enter でコマンド ウィンドウを開きます。
  3. cd to the bin directory of your Bitbucket Server installation directory.
  4. 次のコマンドを実行します。

    tomcat8w //ES//%SERVICENAME%
  5. Click on the Java tab to see the list of current start-up options.
  6. Modify the -XX:MaxPermSize value to be larger. It's recommended to increase by 128mb blocks, testing each increase. Setting a value too high can be just as problematic as one that is too low.

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

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

Edit <bitbucket-install>/bin/setenv.bat and modify the MAX_PERM_SIZE (or BITBUCKET_MAX_PERM_SIZE for Bitbucket Server 3.7-) value to be larger. It's recommended to increase by 128mb blocks, testing each increase. Setting a value too high can be just as problematic as one that is too low.

 

Why does it fail if I copy a setenv.sh from a previous version into the binaries shipped with Bitbucket Server 3.8+?

How to resolve?

 If you are in that situation, please overwrite the setenv.sh by what we shipped in the Bitbucket Server 3.8+ and restart your instance.

If the indications above do not resolve the problem, please raise a support issue on support.atlassian.com. Make sure you generate a heap dump by using How to generate a heap dump before contacting our support and attach it to your issue.

 

 

 

最終更新日 2017 年 5 月 4 日

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

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