メモリー・リーク・ポリシーの構成

WebSphere® Application Server のリーク検出ポリシーは、デフォルトではオフになっています。ご使用のアプリケーションと環境に対応するように、リーク検出、防止、およびアクションのポリシーを構成して、 起こり得るメモリー・リークの報告を受け、対応することができます。 リークの検出、防止、および予防的な修正により、パーシスタントなメモリー不足エラーに直面しているサーバーに保護と回復力が提供されます。 クラス・ローダーのメモリー・リークが検出されると、WebSphere® Application Server は、ログの通知メッセージと JVM ヒープ・ダンプによってその情報をユーザーに通知するので、問題のトラブルシューティングが可能です。さらなる選択肢として、WebSphere Application Server でメモリー・リークを軽減し、可能であれば解決するために、リフレクションやその他の技法を使用することもできます。

始める前に

Java™ Platform, Enterprise Edition (Java EE) アプリケーションの共通エラーは、クラス・ローダーのメモリー・リークです。 メモリー・リークは、小さなアプリケーションのバグからも、サード・パーティーのライブラリーなどの複雑な使用からも発生する可能性があります。 ガーベッジ・コレクションによる CPU 時間や、Java ヒープなどのシステム・リソースは、リークが存在すると消費されます。 他のすべてのリソースが利用できても、システムが無応答となる場合があります。 保護と早期警告システムを構築していないと、システムでこの機能低下状態が続き、最終的にはメモリー不足エラーによって停止する可能性があります。

注: メモリー・リーク検出ポリシーを使用すると、クラス・ローダーのメモリー・リークを検出、防止し、可能な場合にはアクションを取るように WebSphere Application Server を構成できます。 メモリー・リークについて詳しくは、Java Platform, Enterprise Edition アプリケーションのメモリー・リークに関するトピックを参照してください。

このタスクについて

デフォルトでは、リーク検出オプションは使用不可になっています。Java 仮想マシン (JVM) カスタム・プロパティーを使用して、リークの検出、アクション、および防止を使用可能にしたり使用不可にするなど、リーク・ポリシーの値を調整できます。 これらのカスタム・プロパティーは、スタンドアロン・サーバーや管理対象アプリケーション・サーバーにのみ適用可能で、ノード・エージェント、管理エージェント、ジョブ・マネージャー、またはデプロイメント・マネージャーには適用できません。 アプリケーションまたはサーバーのシャットダウン中に、WebSphere Application Server は、メモリー・リークが発生しており、かつ関連するすべてのロード済みのクラスおよびオブジェクトへの参照が保持されているクラス・ローダーを判別します。クラス・ローダーのリークが検出されると、ヒープ・ダンプまたはシステム・ダンプが実行されます。

このサービスのすべてのパーシスタント構成は、JVM カスタム・プロパティーを使用して行います。 管理コンソール・パネルはありません。実行時に構成および管理を行うには、それぞれ MemoryLeakConfig MBean および MemoryLeakAdmin MBean を使用します。ただし、JVM カスタム・プロパティーが構成されるまで、構成の変更は保持されません。

MemoryLeak サービスとその MBean は、アプリケーションおよびサービス要求をホストしているアプリケーション・サーバーでのみアクティブになります。 このサービスは、デプロイメント・マネージャー、ノード・エージェント、管理エージェント、または他のサーバー・タイプ (WebSphere プロキシー・サーバーなど) では、アクティブになりません。

ヒント: このサービスを永続的に使用不可にするには、JVM com.ibm.ws.runtime.component.disableMemoryLeakService カスタム・プロパティーを構成してください。

手順

  1. 以下の表に基づいて、メモリー・リーク・サービスの各種の機能を使用可能にするように、JVM カスタム・プロパティーを作成または変更します。 JVM カスタム・プロパティーの値を変更するには、Java 仮想マシンのカスタム・プロパティーを参照してください。
    表 1. com.ibm.ws.runtime.component.MemoryLeakConfig.detectAppCLLeaks
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.detectAppCLLeaks
    説明 サーバーのシャットダウン中や、アプリケーションが停止した時に、WebSphere Application Server は、リークしているクラス・ローダーを判別して、メモリー・リークのデバッグに役立つ警告や他の追加情報などを出します。『Improved classloader leak detection』PMR も参照してください。
    デフォルト false
    表 2. com.ibm.ws.runtime.component.MemoryLeakConfig.clearAppCLLeaks
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.clearAppCLLeaks
    説明 クラス・ローダーのリークの予防的なメディエーションと修正を可能にします。このプロパティーを true に設定すると、WebSphere Application Server はアプリケーションに代わって仲介し、検出されたクラス・ローダーのリークを修正します。
    デフォルト false
    表 3. com.ibm.ws.runtime.component.MemoryLeakConfig.preventJreMemoryLeaks
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.preventJreMemoryLeaks
    説明 WebSphere Application Server が、スレッド・コンテキスト・クラス・ローダー上の JRE ロード singleton によって引き起こされるメモリー・リークの特定のクラスを除去できるようにします。
    デフォルト true
    表 4. com.ibm.ws.runtime.component.MemoryLeakConfig.generateHeapDumps
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.generateHeapDumps
    説明 true に設定すると、メモリー・リークが検出されたときに、ヒープ・ダンプが作成されます。
    デフォルト true
    表 5. com.ibm.ws.runtime.component.MemoryLeakConfig.leakSweeperDelay
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.leakSweeperDelay
    説明 クラス・ローダーのリークをチェックするためにアプリケーションやモジュールが停止した後の遅延時間。
    デフォルト 10000 (ミリ秒)
    表 6. com.ibm.ws.runtime.component.MemoryLeakConfig.monitorSystemApps
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.monitorSystemApps
    説明 true に設定すると、管理コンソールなど、IBM® が出荷したシステム・アプリケーションのメモリー・リークを監視します。
    デフォルト false
    重要: 次のスレッドとタイマーのリーク JVM カスタム・プロパティーを使用して、リーク・アクション・ポリシーの動作を詳細に調整できます。 ThreadLocal、スレッド、タイマー、および静的リークの各カスタム・プロパティーが使用できるのは、com.ibm.ws.runtime.component.MemoryLeakConfig.clearAppCLLeaks に true が設定されている場合に限られます。
    表 7. com.ibm.ws.runtime.component.MemoryLeakConfig.clearReferencesInterruptThreads. スレッドとタイマーのリーク
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.clearReferencesInterruptThreads
    説明 true に設定すると、WebSphere Application Server は Web アプリケーションによって開始されるスレッドを中断しようとします。 スレッドの中断は、Thread.interrupt() メソッドを使用して実行します。 ターゲット・スレッドが中断に応答しない可能性があります。
    デフォルト true
    表 8. com.ibm.ws.runtime.component.MemoryLeakConfig.clearReferencesHttpClientKeepAliveThread. スレッドとタイマーのリーク
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.clearReferencesHttpClientKeepAliveThread
    説明 HttpClient キープアライブ・タイマー・スレッドがこの Web アプリケーションによって開始されたのではなく、まだ実行されている場合に、WebSphere Application Server はメモリー・リークを防止するために、コンテキスト・クラス・ローダーを現在のクラス・ローダーからその親に変更します。 キープアライブ・スレッドがすべて停止すると、キープアライブ・タイマー・スレッドはそれ自体で停止します。 ただし、ビジー状態のシステムでは、これがしばらくの間発生しない場合があります。
    デフォルト true
    表 9. com.ibm.ws.runtime.component.MemoryLeakConfig.clearReferencesStopTimerThreads. スレッドとタイマーのリーク
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.clearReferencesStopTimerThreads
    説明 true に設定すると、WebSphere Application Server は、Web アプリケーションによって開始された java.util.TimerThread をすべて停止させます。
    デフォルト false
    表 10. com.ibm.ws.runtime.component.MemoryLeakConfig.jvmThreadGroupNames. スレッドとタイマーのリーク
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.jvmThreadGroupNames
    説明 シャットダウンする必要がある Web アプリケーションによって開始されるスレッドをスキャンするときに無視する ThreadGroup の名前のリスト。 このリストは、アンダースコアーによって区切られます。
    デフォルト system__RMI Runtime
    重要: 以下の静的クラス変数のリーク・プロパティーは、com.ibm.ws.runtime.component.MemoryLeakConfig.clearAppCLLeaks に true が設定されている場合にのみ適用されます。
    表 11. com.ibm.ws.runtime.component.MemoryLeakConfig.clearReferencesStatic. 静的クラス変数のリーク
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.clearReferencesStatic
    説明 true に設定すると、WebSphere Application Server は、ガーベッジ・コレクションのバグやアプリケーション・コードのエラーの回避策として、Web アプリケーションが停止したときに、ロードされたクラスの最終フィールドをヌルにしようとします。 このオプションに false を設定しても、最新の JVM を使用しているメモリー・リークのないアプリケーションは、正常に動作するはずです。
    デフォルト false
    表 12. com.ibm.ws.runtime.component.MemoryLeakConfig.filterPrefixes. 静的クラス変数のリーク
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.filterPrefixes
    説明 clearReferencesStatic を true に設定すると、これらのフィルターで開始されるメンバー属性はヌルに設定されません。
    デフォルト java javax com.ibm org sun com.sun. このリストは、スペースで区切られます。
    重要: 以下の Threadlocal リーク・プロパティーは、com.ibm.ws.runtime.component.MemoryLeakConfig.clearAppCLLeaks に true が設定されている場合にのみ適用されます。
    [AIX Solaris HP-UX Linux Windows][IBM i]
    表 13. com.ibm.ws.runtime.component.MemoryLeakConfig.checkThreadLocalLeaks. Threadlocal のリーク
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.checkThreadLocalLeaks
    説明 アプリケーションが停止したときに ThreadLocal リークを検査するかどうかを決定します。
    デフォルト false
    [AIX Solaris HP-UX Linux Windows][IBM i]
    表 14. com.ibm.ws.runtime.component.MemoryLeakConfig.clearReferencesThreadLocal. Threadlocal のリーク
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.clearReferencesThreadLocal
    説明 アプリケーションが停止したときに、スレッド・プールのスレッドを更新することによって、Threadlocal のリークを除去します。 このプロパティーは、分散プラットフォームにのみ適用されます。
    デフォルト true
    重要: 以下のプロパティーは、clearReferencesThreadLocal に true が設定されている場合にのみ適用されます。
    [AIX Solaris HP-UX Linux Windows][IBM i]
    表 15. com.ibm.ws.runtime.component.MemoryLeakConfig.renewThreadPoolNames. Threadlocal のリーク
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.renewThreadPoolNames
    説明 Threadlocal のリークが検出されたときに WebSphere Application Server が更新する必要がある Threadpool の名前。
    デフォルト 「WebContainer」リストはスペースで区切られます。
    [AIX Solaris HP-UX Linux Windows][IBM i]
    表 16. com.ibm.ws.runtime.component.MemoryLeakConfig.threadPoolRenewalDelayFactor. Threadlocal のリーク
    通知
    名前 com.ibm.ws.runtime.component.MemoryLeakConfig.threadPoolRenewalDelayFactor
    説明 スレッド・プールの更新を待機する合計時間を制御します。 スレッド・プールの更新を待機する合計時間 = threadPoolRenewalDelayFactor * threadPool.getKeepAliveTime()
    デフォルト 10. Web コンテナーのスレッド・プールでは、更新の遅延は (10 * 60000 ms) 6 分です。
    [AIX Solaris HP-UX Linux Windows][IBM i]
    表 17. com.ibm.ws.util.ThreadPool.DEFAULT_THREAD_RENEWAL_DELAY. Threadlocal のリーク
    通知
    名前 com.ibm.ws.util.ThreadPool.DEFAULT_THREAD_RENEWAL_DELAY
    説明 アプリケーションが停止した後でプール内のスレッドが更新されます。 このカスタム・プロパティーを使用して、すべてのスレッドが同時に更新されるのを回避します。この遅延は、更新される 2 つのスレッドの間で発生します。
    デフォルト 1000 (値はミリ秒単位)。値が負の場合、スレッドは更新されません。
    これらの JVM カスタム・プロパティーは、server.xml ファイルの WebSphere Application Server の構成モデルで保持されます。 次のコード・スニペットは、管理対象外サーバーの server_home/config/cells/nodes/servers/server.xml ファイルから、保持されたリーク・ポリシー構成を表示します。
    <jvmEntries xmi:id="JavaVirtualMachine_1183122130078" verboseModeClass="true" verboseModeGarbageCollection="true" verboseModeJNI="false" 
    runHProf="false" hprofArguments="" debugMode="false" debugArgs="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7777" 
    genericJvmArguments="-agentlib:getClasses -Xquickstart  -Xalwaysclassgc" executableJarFileName="" disableJIT="false">
    		<systemProperties xmi:id="Property_1317048628648" name="com.ibm.ws.runtime.component.MemoryLeakConfig.detectAppCLLeaks"	value="true"	/>
    		<systemProperties xmi:id="Property_1318975518491" name="com.ibm.ws.runtime.component.MemoryLeakConfig.clearAppCLLeaks"	value="true"	/>
    		<systemProperties xmi:id="Property_1318955284241" name="com.ibm.ws.runtime.component.MemoryLeakConfig.generateSystemDumps"	value="false"	/>
    		<systemProperties xmi:id="Property_1319119976147" name="com.ibm.ws.runtime.component.MemoryLeakConfig.generateHeapDumps"	value="true"	/>
    		<systemProperties xmi:id="Property_1317048628649" name="com.ibm.ws.runtime.component.MemoryLeakConfig.monitorSystemApps"	value="false"	/>
    </jvmEntries>
  2. 適用」をクリックします。
  3. 「OK」をクリックします。
  4. 変更を保存します。 サーバーを再始動する前に、 ファイルの同期が実行されているかどうかを確認します。
  5. アプリケーション・サーバーを再始動して変更を有効にします。

WebSphere Application Server のメモリー・リーク・ポリシーは、この例で説明したように、JVM カスタム・プロパティーを使用して構成および保持できます。実行時に、メモリー・リークの検出、防止、およびポリシーの構成は、MemoryLeakConfig MBean を使用して変更できます。

メモリー・リーク・ポリシーの管理は、MemoryLeakAdmin MBean を使用して実行できます。 リーク・ポリシーは、アプリケーションまたはサーバーが停止したときに、アプリケーション・サーバーがクラス・ローダーのメモリー・リークにどのように応答するかに影響を与えます。

wsadmin スクリプト・インターフェースを使用して、メモリー・リーク・ポリシー設定を調整することができます。 この変更内容はただちに有効になりますが、 サーバー構成に保持されないので、サーバーを再始動すると失われます。 次のスクリプトは、wsadmin jacl スクリプトを使用してメモリー・リーク・ポリシーを構成および管理する方法の例を示します。
# Scripting in JACL

# Get the object name of the MemoryLeak Configiration object  you want to change the values on
set leakConfig [$AdminControl completeObjectName "type=MemoryLeakConfig,*"]
WebSphere:cell=smitaNode03Cell,name=LeakConfig,type=MemoryLeakConfig,node=smitaNode03,process=server1

# Get the object name of the MemoryLeak Administration object  you want to issue operations
set leakAdmin [$AdminControl completeObjectName "type=MemoryLeakAdmin,*"]
WebSphere:cell=smitaNode03Cell,name=LeakAdmin,type=MemoryLeakAdmin,node=smitaNode03,process=server1

# Look at all the attributes of the MemoryLeakConfig mbean
wsadmin>$Help all $leakConfig
Name: WebSphere:cell=smitaNode03Cell,name=LeakConfig,type=MemoryLeakConfig,node=smitaNode03,process=server1
        Description: Information on the management interface of the MBean
        Class name: com.ibm.ws.runtime.component.MemoryLeakConfig

Attribute Type Access
JvmThreadGroupNames             java.lang.String                RW
FilterPrefixes                  java.lang.String                RW
RenewThreadPoolNames            java.lang.String                RW
DetectAppCLLeaks                boolean                         RW
ClearAppCLLeaks                 boolean                         RW
MonitorSystemApps               boolean                         RW
NoDumps                         boolean                         RW
GenerateHeapDumps               boolean                         RW
GenerateSystemDumps             boolean                         RW
ClearReferencesStatic           boolean                         RW
ClearReferencesInterruptThreads   boolean                       RW
ClearReferencesStopTimerThreads   boolean                       RW
ClearReferencesHttpClientKeepAliveThread  boolean               RW
ClearReferencesThreadLocal      boolean                         RW
LeakSweeperDelay                int                             RW
ThreadPoolRenewalDelayFactor    int                             RW
PreventJreMemoryLeaks           boolean                         RW
LeakConfiguration               java.lang.String                RO

Operation
Notifications
Constructors
# Print the current Memory Leak Policy configuration on the console 
wsadmin>$AdminControl getAttribute $leakConfig LeakConfiguration
MemoryLeakConfig [getClass()=class com.ibm.ws.runtime.component.MemoryLeakConfig, hashCode()=37266644
preventJreMemoryLeaks true
detectAppCLLeaks true
         monitorSystemApps false
         leakSweeperDelay 10000
clearAppCLLeaks true
         clearReferencesStopTimerThreads false
         clearReferencesHttpClientKeepAliveThread true
         clearReferencesInterruptThreads true
                  jvmThreadGroupNames [system, RMI Runtime]
         clearReferencesStatic true
                 filterPrefixes [java., javax., com.ibm., org., sun., com.sun]
         clearReferencesThreadLocal true
                  renewThreadPoolNames [WebContainer]
                  threadPoolRenewalDelayFactor 1
noDumps false
         generateHeapDumps true
         generateSystemDumps false

# Change the configuration
wsadmin>$AdminControl setAttribute $leakConfig ThreadPoolRenewalDelayFactor 10
wsadmin>$AdminControl setAttribute $leakConfig ClearReferencesStopTimerThreads true

# See the updated configuration
wsadmin>$AdminControl getAttribute $leakConfig LeakConfiguration
MemoryLeakConfig [getClass()=class com.ibm.ws.runtime.component.MemoryLeakConfig, hashCode()=37266644
preventJreMemoryLeaks true
detectAppCLLeaks true
         monitorSystemApps false
         leakSweeperDelay 10000
clearAppCLLeaks true
         clearReferencesStopTimerThreads true
         clearReferencesHttpClientKeepAliveThread true
         clearReferencesInterruptThreads true
                  jvmThreadGroupNames [system, RMI Runtime]
         clearReferencesStatic true
                 filterPrefixes [java., javax., com.ibm., org., sun., com.sun]
         clearReferencesThreadLocal true
                  renewThreadPoolNames [WebContainer]
                  threadPoolRenewalDelayFactor 10
noDumps false
         generateHeapDumps true
         generateSystemDumps false

# Look at all the operations of the MemoryLeakAdmin mbean
wsadmin>$Help all $leakAdmin
Name: WebSphere:cell=smitaNode03Cell,name=LeakAdmin,type=MemoryLeakAdmin,node=smitaNode03,process=server1
        Description: Information on the management interface of the MBean
        Class name: com.ibm.ws.runtime.component.MemoryLeakAdmin
Operation
java.lang.String findLeaks()
java.lang.String fixLeaks()
java.lang.String fixLeaks(java.lang.String)

# Find current classloader memory leaks
wsadmin>$AdminControl invoke $leakAdmin findLeaks
CWMML0028I: The following web applications were stopped (reloaded, undeployed), but their classes from previous runs are still loaded in memory, thus causing a memory leak.[[78577.075.724.NWALogging#NWALoggingEJB.jar]].

# Fix ALL current classloader memory leaks
wsadmin>$AdminControl  invoke $leakAdmin fixLeaks
CWMML0036I: Please watch the SystemOut log for results of the fix leak operation.

wsadmin>$AdminControl  invoke $leakAdmin fixLeaks {"78577.075.724.NWALogging#NWALoggingEJB.jar"}
CWMML0036I: Please watch the SystemOut log for results of the fix leak operation.

トピックのタイプを示すアイコン タスク・トピック



タイム・スタンプ・アイコン 最終更新: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=ttrb_configmemleak
ファイル名:ttrb_configmemleak.html