heapの見積もり
Even though Ergonomics significantly improves the "out of the box" experience for many applications, optimal tuning often requires more attention to the sizing of the Java memory regions.
Javaのメモリの見積もりにもっと注意を払うことが、チューニングには必要だったりします。
The maximum heap size of a Java application is limited by three factors: the process data model (32-bit or 64-bit) and the associated operating system limitations, the amount of virtual memory available on the system, and the amount of physical memory available on the system.
Javaアプリの最大heapサイズは次の3つの要素で決まります。
- 処理データモデル(32bit or 64bit)とOSの制限
- システム上で利用できる仮想メモリの総量
- システム上で利用できる物理メモリの総量
The size of the Java heap for a particular application can never exceed or even reach the maximum virtual address space of the process data model. For a 32-bit process model, the maximum virtual address size of the process is typically 4 GB, though some operating systems limit this to 2 GB or 3 GB. The maximum heap size is typically -Xmx3800m (1600m) for 2 GB limits), though the actual limitation is application dependent. For 64-bit process models, the maximum is essentially unlimited.
1つのJavaアプリで使えるheapの上限は処理データモデルの仮想アドレス空間の上限を超えることはない。
32bit処理系だと仮想アドレスの上限サイズは4GBである。(上限が2GB、3GBのOSも存在する)。
heapの上限は一般に、3800MB(引数で書くと、-Xmx3800m)。2GBが上限の場合だと1600MB。実際の制限はアプリによるけれどね。
64bit処理系では、実質的に上限は無いといっていい。
訳者注)
OSでの上限が2GBの時javaHeapのmaxが1600MBということのようだけど、この約400MBの理由は後の節を読めばわかるのだろうか?
For a single Java application on a dedicated system, the size of the Java heap should never be set to the amount of physical RAM on the system, as additional RAM is needed for the operating system, other system processes, and even for other JVM operations. Committing too much of a system's physical memory is likely to result in paging of virtual memory to disk, quite likely during garbage collection operations, leading to significant performance issues. On systems with multiple Java processes, or multiple processes in general, the sum of the Java heaps for those processes should also not exceed the the size of the physical RAM in the system.
専用システム上で動く単独のJavaアプリの場合、heapサイズはシステムの物理RAM量と同じにしてはいけない。というのも、OSやシステムの他のプロセスや他のJavaVMでもRAMを必要とするからです。
システムの物理メモリをJavaアプリにあまりにもたくさん割り当てすぎると結果として、GCの間、仮想メモリからHDDへのページングが多発することになったりして深刻なパフォーマンス低下を招くことになる。
複数のJavaプロセスがあるシステムではJavaheapの合計サイズはシステム上の物理メモリのサイズを超えないようにしよう。
The next most important Java memory tunable is the size of if the young generation (also known as the NewSize). Generally speaking the largest recommended value for the young generation is 3/8 of the maximum heap size. Note that with the throughput and low pause time collectors it may be possible to exceed this ratio. For more information please see the discussions of the Young Generation Guarantee in the Tuning Garbage Collection with the 5.0 Java Virtual Machine document.
次に重要なJavaメモリのチューニングポイントは、young領域(NewSizeと呼ばれたりする)のサイズです。
一般には、young領域のオススメサイズは、heapの最大サイズの8分の3です。(heap1GBだと、youngは414MB。思ったより多いかも。)
もっと知りたい人は「the Young Generation Guarantee in the Tuning Garbage Collection with the 5.0 Java Virtual Machine document」でのディスカッションを参照してね。
Additional memory settings, such as the stack size, will be covered in greater detail below.
これ以外のメモリの設定については(stackのサイズとか)は後ろの章で詳しくやるよ。