Azzera filtri
Azzera filtri

Out of memory error: problem loading large .mat file

17 visualizzazioni (ultimi 30 giorni)
Marcelo
Marcelo il 8 Gen 2015
Commentato: Jan il 3 Feb 2021
Hi,
I have a .mat file containing just one big Simulink.ModelDataLogs variable. The names are "myfile.mat" and "mylogsout".
When I try to load this .mat file into the workspace, I receive the error:
"Out of memory. Type HELP MEMORY for your options".
I tried to use the "matfile" command, as
matObj = matfile('myfile.mat');
but this way I can't acess the inner variables in "mylogsout", as
data = matObj.mylogsout.Signal_In.Force.Data;
I want to find a way to load only the variables from the "mylogsout" file that I will use in script.
How can I load only specific variables of the "mylogsout" file? Is it possible?
Thanks,
Marcelo
  5 Commenti
Marcelo
Marcelo il 9 Gen 2015
I'm using a 32 Bit version of Matlab.
Yes, split the Simulink.ModelDataLogs variable probably will work.
I will try do that before I save the .mat file.
Sean Little
Sean Little il 11 Nov 2019
I am having the same problem, with almost the same situation. I have a matfile with a lot of simulink simulation data (72G) that I am trying to load using the MATFILE command. I thought that was the whole point of using the MATFILE command instead of LOAD...to avoid loading the whole file into memory at once? But it appears to be attempting to load the entire 72G file into memory on my 16G machine, and matlab just crashes and exits silently.
I'm using 64 bit matlab.
Is this a bug or expected behavior?

Accedi per commentare.

Risposte (1)

Jan
Jan il 9 Gen 2015
The message means, that the computer does not have enough free memory to store the variable. Is it possible to free memory e.g. by clearing unused variables or stopping other applications? Increasing the virtual memory can help also, but the best method is installing more RAM.
It is possible to create a MEX function, which imports specific fields of a struct only. But I'm convinced that the development and testing is more expensive than buying 4GB of additional RAM.
  3 Commenti
Tan Nguyen
Tan Nguyen il 3 Feb 2021
Dear Jan,
All variables in Workplace could be saved as a .mat file. It is about 1.2GB. However, as I load it, it is opened incompletely. Some variables miss. Matlab warns "Out of memory". How can it be fixed?
I am using 128GB RAM.
Thank you,
Jan
Jan il 3 Feb 2021
If Matlab runs out of memory, either the arrays occupy much more memory than the MAT files. This is possible, because MAT files are compressed such that zeros(1,1e9) does not need 8e9 bytes in the MAT file. Or the RAM is exhausted by other data already, such that even 1.2MB do not fit anywhere.
Check the contents of the MAT file and the available RAM. Use:
whos
whos -file YourFile.mat

Accedi per commentare.

Categorie

Scopri di più su Workspace Variables and MAT-Files in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by