What is the largest size of matrix? Error message: there is not enough memory to complete this command


#1

Hi,

I am trying to create a matrix variable using script.
But it seems the size of matrix is limited by program to prevent memory problem.
What is the biggest size of matrix?


#2

Dear @mooncm

This is an interesting question, and is a very useful feature to avoid crashing your computer.

An error message like there is not enough memory to complete this command shows up when you try to create a large matrix (such as matrix(1e6,1e6);). After discussing it with my colleagues, it looks like the cap for matrix size is limited by the C/C++ which the programming language of our tools. I am not expert on how C/C++ algorithm checks the available memory, but I assume it somehow retrieves the system information (might be on demand or on real time). Obviously this will depend on your operating system. I will request this as a new feature that can be added to our tools which will allow users to check their memory and max size of the matrix that they can have before crashing the software.

If you are interested to get a feeling on what would be the max matrix size on your system, these MATLAB documentation will be quite useful:
https://www.mathworks.com/matlabcentral/answers/91711-what-is-the-maximum-matrix-size-for-each-platform
http://stackoverflow.com/questions/7328044/matrix-size-limitation-in-matlab

On a different note, if you are working with larger matrix, you can probably save it in smaller files and load them for post processing.

Downsampling might be another useful trick to lower the size of the matrix. These links might be useful for your review:
https://kb.lumerical.com/en/ref_scripts_interp.html

I hope this was helpful.
Thanks