Managing a Java Out of Memory Error

If you encounter a Java OutOfMemoryError, you can try executing your program again by restarting SAS and specifying a larger amount of memory for Java at SAS invocation.
To determine what the current Java memory settings are, you can submit a PROC OPTIONS statement that shows the value of the JREOPTIONS option:
proc options option=jreoptions; 
run;
After you submit this procedure code, a list of JREOPTIONS settings is displayed in the SAS log. The JREOPTIONS option has many suboptions that configure the SAS Java environment. Many of the suboptions are installation and host specific and should not be modified, especially the ones that provide installed file locations. For managing memory, look for the -Xmx and -Xms suboptions:
JREOPTIONS=(/* other Java suboptions */ -Xmx128m -Xms128m)
-Xms
Use this option to set the minimum Java memory (heap) size, in bytes. Set this value to a multiple of 1024 greater than 1MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default is 2MB. Examples:
-Xms6291456
-Xms6144k
-Xms6m
-Xmx
Use this option to set the maximum size, in bytes, of the memory allocation pool. Set this value to a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default is 64MB. Examples:
-Xmx83886080
-Xmx81920k
-Xmx80m
As a general rule, you should set the minimum heap size (-Xms) equal to the maximum heap size (-Xmx) to minimize garbage collections.
Typically, SAS sets both -Xms and -Xmx to be about 1/4 of the total available memory or a maximum of 128M. However, you can set a more aggressive maximum memory (heap) size, but it should never be more than 1/2 of physical memory.
You should be aware of the maximum amount of physical memory your computer has available. Let us assume that doubling the Java memory allocation is feasible. So when you start SAS from a system prompt, you can add the following option:
-jreoptions (-Xmx256m -Xms256m)
Alternatively, you might need to specify the setting in quotation marks:
-jreoptions '(-Xmx256m -Xms256m)'
The exact syntax varies for specifying Java options, depending on your operating system, and the amount of memory that you can allocate varies from system to system. The set of JRE options must be enclosed in parentheses. If you specify multiple JREOPTIONS system options, SAS appends JRE options to JRE options that are currently defined. Incorrect JRE options are ignored.
If you choose to create a custom configuration file, you would simply replace the existing -Xms and -Xmx suboption values in the JREOPTIONS=(all Java options) portion of the configuration file.
For more information, see the SAS Companion for your operating system.