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

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

I cannot recall having this problem. Could you add the code you tried. I have had some problems saving complicated structs though for some save formats. It is possible that saving file in format '-v7.3' would help but I am not sure.
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)

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

I did more-or-less the same experiment. I have less computer than you do so I had to make the structures smaller(XP, 32B, 4GB). I got more-or-less the same result as you (i.e. this didn't replicate the problem). One notable difference was that my mat files were big enough (with respect to my computer) that I had to clear between loads and you did not. If I did that, I was able to load at least 6 times. Whatever is happening with the actual mat files doesn't seem to get flushed out sufficiently by the clear command in the same way. When I did not clear between loads, I got the same error message that I have been getting (i.e. "can't load file") without any reference to a memory issue. I FTP'd some of the actual mat files to tech support.
"A coworker with the same version of matlab on a newer better computer with a different OS has the same problem." &nbsp What is the spec of this "better computer" ?
As I recall, win7 64B 16GB RAM. I don't recall the CPU, but it was high end when bought new less than 2 years ago. I don't know what her Java heap size setting is. Increasing mine did not seem to help. She hasn't been in the office this week, so I have not had the opportunity to ask her how clearing between loading changes things (if at all) on her computer. The mat files are obviously a lot smaller from the perspective of her computer than mine, although she tends to keep a lot of things open at once and might not have considered that this is a memory issue since the error message makes no reference to that.
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.
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

Asked:

on 29 Jul 2014

Edited:

on 2 Aug 2014

Community Treasure Hunt

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

Start Hunting!