ラベル チューニング の投稿を表示しています。 すべての投稿を表示
ラベル チューニング の投稿を表示しています。 すべての投稿を表示

2014/06/27

Why reduce the size of the Java JVM thread stack

★あれ、threadStack is out of heap...

When Java creates a new thread, it pre-allocates a fixed-size block of memory for that thread's stack. By reducing the size of that memory block, you can avoid running out of memory, especially if you have lots of threads - the memory saving is the reduction in stack size times the number of threads.

The downside of doing this is that you increase the chance of a Stack Overflow error.

Note that the thread stacks are created outside of the JVM heap, so even if there's plenty of memory available in the heap, you can still fail to create a thread stack due to running out of memory (or running out of address space, as Tom Hawtin correctly points out).

2014/06/13

java MemoryUsage チューニング

MemoryUsage オブジェクトには、次の 4 つの値があります。

    初期値:init     起動中に Java 仮想マシンがオペレーティングシステムから要求するメモリー管理のための初期メモリー量 (バイト単位) を表す。Java 仮想マシンは、オペレーティングシステムから追加のメモリーを要求したり、システム時間の経過とともにメモリーを解放したりすることもできる。init の値は指定しなくてもかまわない
    現在値:used     現在使用されているメモリーの量 (バイト単位) を表す
    確保値:committed     Java 仮想マシンが使用できることが保証されているメモリーの量 (バイト単位) を表す。 コミットされたメモリーの量は、時間の経過とともに変化 (増減) する。Java 仮想マシンはシステムに対してメモリーを解放できる。committed は init 未満であることも可能。 committed は、常に used 以上になる
    最大値:max     メモリー管理に使用できる最大メモリー量 (バイト単位) を表す。この値は定義しないことも可能。定義する場合、メモリーの最大量は時間の経過とともに変化する可能性がある。max が定義された場合、used および committed メモリーの量は常に max 以下になる。used <= max が true の場合でも used > committed などのように、used メモリーを増やそうとするとメモリーの割り当てが失敗する可能性がある (たとえば、システムの仮想メモリーが少ない場合)
   
 例:HeapSize=1024M
initの値:
  PS Old Gen  683M
   PS Eden Space 256M
   PS Survivor Space 42M

==>newRadioの最適値は?683/(256+42)=2.2 デフォルト値は2、まぁ。。大体。。
==>xmxの最適値は?683+256+42=981M ギリギリ。
==>SurvivorRatioの最適値は? 256/42=6.09 デフォルトは8 ここはちょっと調整できる。