JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio 12.2: C++ User's Guide
search filter icon
search icon

Document Information


Part I C++ Compiler

1.  The C++ Compiler

2.  Using the C++ Compiler

2.1 Getting Started

2.2 Invoking the Compiler

2.2.1 Command Syntax

2.2.2 File Name Conventions

2.2.3 Using Multiple Source Files

2.3 Compiling With Different Compiler Versions

2.4 Compiling and Linking

2.4.1 Compile-Link Sequence

2.4.2 Separate Compiling and Linking

2.4.3 Consistent Compiling and Linking

2.4.4 Compiling for 64-Bit Memory Model

2.4.5 Compiler Command-Line Diagnostics

2.4.6 Understanding the Compiler Organization

2.5 Preprocessing Directives and Names

2.5.1 Pragmas

2.5.2 Macros With a Variable Number of Arguments

2.5.3 Predefined Names

2.5.4 Warnings and Errors

2.6 Memory Requirements

2.6.1 Swap Space Size

2.6.2 Increasing Swap Space

2.6.3 Control of Virtual Memory

2.6.4 Memory Requirements

2.7 Using the strip Command with C++ Objects

2.8 Simplifying Commands

2.8.1 Using Aliases Within the C Shell

2.8.2 Using CCFLAGS to Specify Compile Options

2.8.3 Using make Using CCFLAGS Within make

3.  Using the C++ Compiler Options

Part II Writing C++ Programs

4.  Language Extensions

5.  Program Organization

6.  Creating and Using Templates

7.  Compiling Templates

8.  Exception Handling

9.  Improving Program Performance

10.  Building Multithreaded Programs

Part III Libraries

11.  Using Libraries

12.  Using The C++ Standard Library

13.  Using the Classic iostream Library

14.  Using the Complex Arithmetic Library

15.  Building Libraries

Part IV Appendixes

A.  C++ Compiler Options

B.  Pragmas



2.6 Memory Requirements

The amount of memory a compilation requires depends on several parameters, including:

On the SPARC platform, if the optimizer runs out of memory, it tries to recover by retrying the current procedure at a lower level of optimization. The optimizer then resumes subsequent routines at the original level specified in the -xOlevel option on the command line.

If you compile a single source file that contains many routines, the compiler might run out of memory or swap space. Try reducing the level of optimization. Alternately, split the largest procedures into separate files of their own.

2.6.1 Swap Space Size

The swap -s command displays available swap space. See the swap(1M) man page for more information.

The following example demonstrates the use of the swap command:

example% swap -s
total: 40236k bytes allocated + 7280k reserved = 47516k used, 1058708k available

2.6.2 Increasing Swap Space

Use mkfile(1M) and swap (1M) to increase the size of the swap space on a workstation. (You must become superuser to do this.) The mkfile command creates a file of a specific size, and swap -a adds the file to the system swap space:

 example# mkfile -v 90m /home/swapfile
 /home/swapfile 94317840 bytes
 example# /usr/sbin/swap -a /home/swapfile

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 4 Gbytes:

 example$ ulimit -d 4000000

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 4 Gbytes:

 example% limit datasize 4G

Each of these examples causes the optimizer to try to recover at 4 Gbytes 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 8 Gbytes of swap space, use the following commands:

In an sh shell:

example$ ulimit -d 4000000

In a csh shell:

example% limit datasize 4G

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

2.6.4 Memory Requirements

A workstation should have at least 2 gigabytes of memory. See the product release notes for detailed requirements.