Out of memory error: problem loading large .mat file
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
Sean Little
2019-11-11
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?
回答(1 个)
Jan
2015-1-9
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 个评论
Tan Nguyen
2021-2-3
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
2021-2-3
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!