はい、上限はありますが、システムによって異なります。試してみて、限界に達するまで 2 倍にしてから検索してみてください。少なくとも Linux で Sun JRE 1.6 を使用すると、常に有益なエラー メッセージが表示されるわけではありませんが、興味深い結果が得られます (peregrino は、2G RAM でスワップなしで 32 ビットの ubuntu を実行するネットブックです)。
peregrino:$ java -Xmx4096M -cp bin WheelPrimes
Invalid maximum heap size: -Xmx4096M
The specified size exceeds the maximum representable size.
Could not create the Java virtual machine.
peregrino:$ java -Xmx4095M -cp bin WheelPrimes
Error occurred during initialization of VM
Incompatible minimum and maximum heap sizes specified
peregrino:$ java -Xmx4092M -cp bin WheelPrimes
Error occurred during initialization of VM
The size of the object heap + VM data exceeds the maximum representable size
peregrino:$ java -Xmx4000M -cp bin WheelPrimes
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
(experiment reducing from 4000M until)
peregrino:$ java -Xmx2686M -cp bin WheelPrimes
(normal execution)
-Xmx4095M はかなり奇妙で (おそらく符号付き/符号なしの比較?)、スワップなしで 2GB マシンに 2686M を予約すると主張していることを除いて、ほとんどは一目瞭然です。ただし、OS でそれだけのアドレス指定が許可されている場合、32 ビット VM の最大サイズは 2G ではなく 4G であることを示唆しています。