**Platform:**All Platforms

**Versions:**All versions

## Problem Description

I get an error message, that contains the words **Out of memory**, for example:

`Out of memory during LU factorization. `

or

` Out of memory during assembly `

## Solution

### Background

Before resolving this issue, you should go through the following steps:

#### 1) Check the amount of available memory on your system

First, check how much installed memory (RAM) is in your computer. The reason for out of memory error messages is that COMSOL is requesting more memory from the operating system than is available on your computer. Most operating systems will also be using the hard drive (virtual memory) to store data. However, using virtual memory is slower than storing data in RAM, therefore the virtual memory will not, by default, be much greater than the installed RAM memory. COMSOL requests memory from the operating system and will always use both the physical RAM and virtual memory available on your system.

#### 2) Check the size of your COMSOL model

Next, check the number of degrees of freedom (DOFs) in your model. This will be reported in the **Messages** window within the COMSOL GUI when you start to solve the problem. Knowledge Base 875 describes how to approximately predict the number of degrees of freedom based upon the mesh. The number of DOFs is related to the amount of memory a particular model will need.

#### 3) Predict your memory requirements by solving smaller models

Start by solving smaller models with the same physics, or use a coarser mesh to solve the same model. Monitor the memory requirements and DOFs for these smaller models. Fit a second order polynomial curve to this data to roughly predict how much memory you will need for the actual problem that you want to solve. Knowing the size of the models that you want to solve is important.

### Resolutions

Once you know how much memory is installed in your system and have a rough idea of how much memory your model will take you can consider one of several possible approaches.

#### 1) Use a computer with more memory

See if you have access to a machine with the needed amount of memory. If you are using a Floating Network License you can also solve on a cluster.

If you anticipate running many models of similar size, then it is reasonable to consider a hardware upgrade. See Knowledge Base solution 866 for hardware recommendations.

#### 2) Simplify your problem

Several different techniques can be used here, investigate some or all of these suggestions.

##### Exploit symmetry

If your geometry has any symmetry (or near symmetry) and you expect your solution to also be symmetric (or nearly symmetric) consider if you can reduce your problem size. For example, if a 3D geometry has uniform cross-section in one direction, consider reducing it down to a 2D model. Similarly, if a 3D geometry is unfirm (or nearly so) around an axis of revolution, consider reducing it down to a 2D axisymmetric model.

##### Avoid modeling thin structures

Often, a thin-walled structure or a small gap does not need to be explicitly modeled. Most physics interfaces include boundary conditions which can be used to represent thin structures, thereby avoiding modeling, and meshing, of thin domains.

##### Reduce the geometric complexity

Carefully check your geometry to see if it contains any features that you do not actually need for your analysis. Remove cosmetic features. If you are working with CAD data coming from another source, use the **Defeaturing and Repair** operations to remove any small faces not critical for analysis. Please read Working with Imported CAD Designs for more details.

##### Use virtual operations

Virtual operations are used to approximate the geometry for the purposes of meshing. They can be useful on any geometry to quickly ignore details which are not critical to the analysis. Please read Using Virtual Operations to Simplify Your Geometry for more details. For an example of this technique, please see: "Virtual Operation on a Wheel Rim Geometry" http://www.comsol.com/model/virtual-operation-on-a-wheel-rim-geometry-14317

#### 3) Use submodeling

Submodeling is the process of solving a sequence of models with different levels of details and different meshes. For an example of this technique, please see: "Submodeling Analysis of a Shaft" http://www.comsol.com/model/submodeling-analysis-of-a-shaft-20359

#### 4) Use assembly meshing

Depending upon the physics which you are using you may be able to use assembly meshing. This will allow you to have non-congruent meshes if you have assemblies of parts that have different feature sizes. This functionality is particularly recommended for problems involving solid mechanics and heat transfer. See Knowledge Base solution 1216 for more details.

#### 5) Use a different mesh

You will always want to study different mesh sizes. A finite element solution must be verified by repeating the solution on different sized meshes. Always start with as coarse a mesh as possible and gradually decrease the mesh size while observing by how much the solution changes. As you refine the mesh, the finite element solution will become increasingly accurate. Investigate using adaptive mesh refinement or manual meshing.

#### 6) Use a lower discretization

Many physics by default use a second order, quadratic, discretization. Investigate using a first order, linear, discretization order. This can and should be done in conjunction with studying different meshes. For more details, please see: Keeping Track of Element Order in Multiphysics Models

#### 7) Use a different solver

If you are working on 1D, 2D, or 2D-axisymmetric models the memory requirements are usually quite low, first consider a hardware upgrade. If you are solving a model with several physics the default behavior in most cases is to use a fully coupled approach to solve all physics simultaneously. Switch to a segregated approach to solving the multiphysics problem.

If you are working on 3D models the default solvers are usually Iterative for single physics problems, but certain physics do default to using Direct solvers. Iterative solvers require less memory, and are faster, than Direct solvers. If a Direct solver is being used, investigate if an Iterative solver can be used instead. For models with several physics the software will default to using a segregated approach and solve each physics separately using either a Direct or Iterative solver.

For more details, see: Understanding the Fully Coupled vs. Segregated approach and Direct vs. Iterative linear solvers

See also:

COMSOL makes every reasonable effort to verify the information you view on this page. Resources and documents are provided for your information only, and COMSOL makes no explicit or implied claims to their validity. COMSOL does not assume any legal liability for the accuracy of the data disclosed. Any trademarks referenced in this document are the property of their respective owners. Consult your product manuals for complete trademark details.