2.3. Allocating Enough Memory and Solving OutOfMemoryErrorsΒΆ

With GNATbench installed, you may get OutOfMemoryErrors raised by Eclipse. If this happens, it’s likely the case that your Java Virtual Machine doesn’t reserve enough memory for Eclipse. There are two ways of solving this problem. If the error is raised at startup, you may want to increase the initial amount of memory reserved by the virtual machine. By default, Eclipse will allocate up to 256 megabytes. But it allows you to pass arguments directly to the Java VM using the -vmargs command line argument, which must follow all other Eclipse specific arguments. Thus, to increase the available heap memory, you would typically use:

eclipse -vmargs -Xmx<memory size>

with the <memory size> value set to greater than “256M” (256 megabytes – the default).

When using a Sun VM, you may also need to increase the size of the permanent generation memory. The default maximum is 64 megabytes The maximum permanent generation size is increased using the -XX:MaxPermSize= argument:

eclipse -vmargs -XX:MaxPermSize=<memory size>

This argument may not be available for all VM versions and platforms; consult your VM documentation for more details.

Note that specifying memory sizes larger than the amount of available physical memory on your machine will cause Java to “thrash” as it copies objects back and forth to virtual memory, which will severely degrade your performance.