Ruben wrote:It's true that you are getting an OutOfMemoryError in your code. But, is it the boxing operation that is causing it?
Ruben wrote:The following code gives the same error, with no boxing operation in sight:
Ruben wrote:Also, you can't still say that you will be able to cause an OutOfMemoryError reliably in any scenario, as the error taking place is dependent on the amount of memory available to the JVM.
Ruben wrote:I guess that I am looking at things from a more theoretical point of view, whereas you are taking into consideration the environment
The maximum theoretical heap limit for the 32-bit JVM is 4G. Due to various additional constraints such as available swap, kernel address space usage, memory fragmentation, and VM overhead, in practice the limit can be much lower. On most modern 32-bit Windows systems the maximum heap size will range from 1.4G to 1.6G. On 32-bit Solaris kernels the address space is limited to 2G. On 64-bit operating systems running the 32-bit VM, the max heap size can be higher, approaching 4G on many Solaris systems. ... If your application requires a very large heap you should use a 64-bit VM on a version of the operating system that supports 64-bit applications.
On 64-bit VMs, you have 64 bits of addressability to work with resulting in a maximum Java heap size limited only by the amount of physical memory and swap space your system provides.
Ruben wrote:Obviously only things that allocate memory can cause an OOME.