Sun Studio 12: C++ User's Guide

2.6.3 Control of Virtual Memory

Compiling very large routines (thousands of lines of code in a single procedure) at -xO3 or higher can require a large amount of memory. In such cases, performance of the system might degrade. You can control this by limiting the amount of virtual memory available to a single process.

To limit virtual memory in an sh shell, use the ulimit command. See the sh(1) man page for more information.

The following example shows how to limit virtual memory to 16 Mbytes:


 example$ ulimit -d 16000

In a csh shell, use the limit command to limit virtual memory. See the csh(1) man page for more information.

The next example also shows how to limit virtual memory to 16 Mbytes:


 example% limit datasize 16M

Each of these examples causes the optimizer to try to recover at 16 Mbytes of data space.

The limit on virtual memory 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 swap space.

With 32 Mbytes of swap space, use the following commands:

In an sh shell:


example$ ulimit -d 16000

In a csh shell:


example% limit datasize 16M

The best setting depends on the degree of optimization requested and the amount of real memory and virtual memory available.