is there a mat file loading error or memory leak in matlab 2013a?

1 view (last 30 days)
I have a bunch of mat files that I saved. They are all more-or-less the same and contain three structures with a bunch of fields. The largest structure is about 500 MB, but trimming it down doesn't seem to change things. I would like to reload the mat files one at a time, but I can't because I get an error when I load them. I also have matlab 7.01 and it doesn't have the problem even though the mat files were all generated in 2013a.
The error message just says "error using load, can't read file" so it doesn't have any diagnostically useful information. If I shut down matlab and restart it, then I can read the first mat file that I try to, but I get this error message on the 2nd. If I then clean up memory (clear;close all;fclose all;pack), I can load the second mat file, but I get an error loading the 3rd. If I clean up the memory again, I still get the error loading the third and I am stuck. A coworker with the same version of matlab on a newer better computer with a different OS has the samne problem.
  3 Comments
jim Martin
jim Martin on 31 Jul 2014
I can't really add the code because it only involved "load" from the command line. If I added the mat files it would be pretty big.

Sign in to comment.

Answers (1)

per isakson
per isakson on 31 Jul 2014
Edited: per isakson on 31 Jul 2014
This little experiment with R2013a,64bit,Win7,8GB doesn't reproduce your problem.
>> tic, cssm, toc
Name Size Bytes Class Attributes
S1 1x1 576000528 struct
S2 1x1 576000528 struct
S3 1x1 576000528 struct
Name Size Bytes Class Attributes
S1 1x1 576000528 struct
S2 1x1 576000528 struct
S3 1x1 576000528 struct
Elapsed time is 32.391028 seconds.
where
function cssm( )
clear
S1.f1 = cumsum(ones( 3, 8e6 ), 1 );
S1.f2 = cumsum(ones( 3, 8e6 ), 1 );
S1.f3 = cumsum(ones( 3, 8e6 ), 1 );
S2.f1 = cumsum(ones( 3, 8e6 ), 1 );
S2.f2 = cumsum(ones( 3, 8e6 ), 1 );
S2.f3 = cumsum(ones( 3, 8e6 ), 1 );
S3.f1 = cumsum(ones( 3, 8e6 ), 1 );
S3.f2 = cumsum(ones( 3, 8e6 ), 1 );
S3.f3 = cumsum(ones( 3, 8e6 ), 1 );
whos
save( 'c:\tmp\ThreeStruct_1.mat', 'S1', 'S2', 'S3' )
save( 'c:\tmp\ThreeStruct_2.mat', 'S1', 'S2', 'S3' )
save( 'c:\tmp\ThreeStruct_3.mat', 'S1', 'S2', 'S3' )
clear S1 S2 S3
load( 'c:\tmp\ThreeStruct_1.mat', 'S1' )
load( 'c:\tmp\ThreeStruct_2.mat', 'S2' )
load( 'c:\tmp\ThreeStruct_3.mat', 'S3' )
whos
end
&nbsp
&nbsp
The MathWorks need our help to find problems in Matlab. You make them a favor by reporting a reproducible problem.
Report the problem and ask the tech-support for a place to which you can upload your mat-files. Preferably, you should provide a step-by-step description on how to reproduce the problem.
  5 Comments
jim Martin
jim Martin on 1 Aug 2014
OK, I heard back from tech support. The problem seems to have been the Java heap size. I had sought to fix this by making it big. I thought that didn't help, but it actually hurt. Making it small was the way to go. I am not sure how this will sort out on my colleague's computer because it don't know where she has that set.
per isakson
per isakson on 1 Aug 2014
Edited: per isakson on 2 Aug 2014
To me that sounds as if
  • you encountered a memory issue on your computer
  • by decreasing the Java heap size you free memory to be used to store variables
  • error messages are not always as informative as one would like them to be
However, it remains a mystery to me that the problem occurred with your colleague's computer.
Furthermore, why does this memory shortage occur despite the large swap-file? Are there restrictions on how Matlab uses the swap-file?

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!