Search code examples
c#ilnumerics

Exception System.OutOfMemoryException was thrown.in linesolve ilnumerics


I have a problem with linesolve in ilnumerics. Here are the code:

A = A_damped; // (6691x3000) array
D = d_damped; // array size 6691

ILArray<double> AA = A; // AA matrix (3000x6691) so should be transposed
 AA = AA.T;
ILArray<double> BB = D; // matrix (6691 x 1) 
ILArray<double> CC = ILMath.linsolve(AA, BB);

and I got the following notifications :

Exception of type 'System.OutOfMemoryException' was thrown.

is there anyone here has a clue?


Solution

  • Next to the suggestions by @Luaan make sure that your problem size is in a reasonable range. Your matrix consumes ~153MB. Linsolve needs some temporary memory as well. More is needed for temporary arrays during general computations. As a very rough rule of thumb, your problem size should not exceed 1 third of the RAM available to your application. This is hard to determine reliably, since there are always other processes running on the system, consuming memory as well ...

    • The first thing when you encounter OOM issues is to target 64bit.
    • Make sure to use the latest version of ILNumerics. As of today this is 4.10.
    • If this does not reliably remove the OOMs you will have to decrease your problem size or use distributed memory instead.