20.3. How and When to Perform Memory Management

The following topics provide guidance as to when the -m command line option may be necessary:

20.3.1. Determining When to Change the Work Space

The -m command line option allows you to manually set the size of the initial block of memory used by Mechanical APDL. Memory allocated upon startup via the -m option exists in one contiguous block. For example, a -m setting of 1800 with a -db option of 300 instructs the program to allocate an 1800 MB contiguous block of memory with a 300 MB contiguous block reserved for the database and a 1500 MB contiguous block reserved for scratch memory (1800 - 300 = 1500).

The current defaults are -m = 2048 and -db = 1024. Ideally, all program memory will be allocated from within the initial block, allowing efficient reuse of memory blocks during various phases of simulation. When the program needs more memory, it will allocate from the system, automatically growing new blocks that are half the size of the initial scratch memory block or the size of the new memory block allocation, whichever is larger.

One reason to change the default memory settings is when a job fails due to insufficient memory that may be caused by fragmented memory. For example, if a large model requires a contiguous block of 1600 MB for the sparse solver, the default memory allocation is insufficient (-m 2048 MB minus -db 1024 MB = 1024 MB contiguous memory). In this case, the program tries to allocate an additional 1600 MB block of contiguous memory to satisfy the sparse solver requirement, bringing the total memory requirement to 3648 MB (2048 default plus 1600 additional). This memory request may fail on smaller systems. To accommodate this model within the default memory availability, specify -db -100. (Using a negative value prevents the program from allocating additional memory for the database.) The result is an initial memory block of 1948 MB, sufficient to satisfy the sparse solver requirement of 1600 MB.

In some cases, you may want to specifically control how much memory the program can allocate from the system, useful in a multi-user environment where resources such as physical memory are being shared by multiple running analysis jobs. You can set a fixed-memory mode by specifying a negative -m value. When the fixed memory mode is used, the initial database and scratch spaces are set per the -m (and -db) sizes; however, the program is constrained so that it cannot grow any additional memory (for scratch or database). With this option, the program will fail if the memory required by the program exceeds the initial block reserved at startup.

20.3.2. Changing the Amount of Work Space

The easiest way to change the amount of program work space is to use the work space entry option (-m) while activating the program, either via the launcher or via the program execution command.

Example 20.1: Setting the Program Work Space at Startup

To request 1400 MB of program work space (instead of the 2 GB default), issue this command:

ansys242 -m 1400

Other ways to change the work space are:

  • Specifying the work space size you want on the dialog boxes that appear when you select interactive mode or batch mode from the program launcher.

  • Using a different VIRTM_MB value in your config.ans file. A later section in this chapter discusses this file in detail.

Use caution when specifying a value for the -m option. Entering an amount larger than needed wastes system resources and can degrade system performance.

Given a fixed amount of database space, changing the amount of work space changes the available scratch space but holds the database space constant:

Figure 20.3: Changing Work Space

Changing Work Space

20.3.3. Changing the Amount of Database Space

The easiest way to change the amount of database space is to use the database space entry option (-db) while activating the program, either via the launcher or via the program execution command.

Example 20.2: Setting the Database Space at Startup

To request 200 MB of database space (instead of the 1024 MB default), issue this command:

ansys242 -db 200

Given a fixed amount of program work space, allocating more database space leaves less for scratch space and vice versa, as shown:

Figure 20.4: Dividing Work Space

Dividing Work Space

Although all of the above diagrams correspond to a -m value of 2048 MB, their -db values correspond to 1024, 512, and 1536 MB, respectively.

When you are about to solve a large model and the memory requirements are approaching your system's memory limits, you may need to control the amount of database space differently. Run the solution phase as a batch job with minimal -db space (for example, 64 MB). To insure enough scratch space, use a negative value (for example, -db -64) to prevent the program from allocating additional memory required to hold the database. By reducing the amount of database space, the amount of memory available for scratch space during solution is increased. Before postprocessing, restart the program with an increased -db value and resume the jobname.db file.