A compilation may need to use a lot of memory. This will depend on the optimization level chosen and the size and complexity of the files being compiled. On SPARC platforms, if the optimizer runs out of memory, it tries to recover by retrying the current procedure at a lower level of optimization and resumes subsequent routines at the original level specified in the -On option on the command line.
A workstation should have at least 24 megabytes of memory; 32 megabytes are recommended. Memory usage depends on the size of each procedure, the level of optimization, the limits set for virtual memory, the size of the disk swap file, and various other parameters.
Compiling a single source file containing many routines could cause the compiler to run out of memory or swap space.
If the compiler runs out of memory, try reducing the level of optimization, or split multiple-routine source files into files with one routine per file, using fsplit(1).
The SunOS command, swap -s, displays available swap space. See swap(1M).
Example: Use the swap command:
demo% swap -s total: 40236k bytes allocated + 7280k reserved = 47516k used, 1058708k available
demo% /usr/sbin/dmesg | grep mem mem = 655360K (0x28000000) avail mem = 602476544
Use mkfile(1M) and swap(1M) to increase the size of the swap space on a workstation. You must become superuser to do this. mkfile creates a file of a specific size, and swap -a adds the file to the system swap space:
demo# mkfile -v 90m /home/swapfile /home/swapfile 94317840 bytes demo# /usr/sbin/swap -a /home/swapfile
Compiling very large routines (thousands of lines of code in a single procedure) at optimization level -O3 or higher may require an unreasonable amount of memory. In such cases, performance of the system may degrade. You can control this by limiting the amount of virtual memory available to a single process.
In a sh shell, use the ulimit command. See sh(1).
Example: Limit virtual memory to 16 Mbytes:
demo$ ulimit -d 16000
In a csh shell, use the limit command. See csh(1).
Example: Limit virtual memory to 16 Mbytes:
demo% limit datasize 16M
Each of these command lines causes the optimizer to try to recover at 16 Mbytes of data space.
This limit cannot be greater than the system's total available swap space and, in practice, must be small enough to permit normal use of the system while a large compilation is in progress.
Be sure that no compilation consumes more than half the space.
Example: With 32 Mbytes of swap space, use the following commands:
demo$ ulimit -d 1600
demo% limit datasize 16M
The best setting depends on the degree of optimization requested, and the amount of real memory and virtual memory available.
In 64-bit Solaris 7 environments, the soft limit for the size of an application data segment is 2 Gbytes. If your application needs to allocate more space, use the shell's limit or ulimit command to remove the limit. For csh use:
demo% limit datasize unlimited
demo$ ulimit -d unlimited
See the Solaris 7 64-bit Developer's Guide for more information.