Search code examples
javajvmjvm-arguments

Why do you need to specify the Java heap size?


I have always wondered, why does Java require you set the heap size manually? I was under the impression that programs written in other languages would just allocate as much memory as needed as the program run until the OS could allocate no more.

In the Java world we need to set the heap, stack, and permgen size. While this is simple enough forgetting to increase these to "large enough" numbers is the #1 reason I have seen servers go down.

Why is it not possible to tell Java to grow the heap/stack/permgen as much as it needs over time?


Solution

  • My interpretation is that Sun is a company focused on selling Big Boxes and they like that the sysadmins can do things on these boxes. Running a system to fill all the memory is a good way to run it into the ground and be unable to efficiently take action to restore operation because you cannot allocate memory to create a login shell for example.