MATLAB Answers

Bert

Error using save: Error closing file

Asked by Bert
on 12 Oct 2011
Latest activity Answered by Jonathan Pelham
on 17 Feb 2015

Hey all,

An instance of a class is filled with a lot of data and than saved to my harddisk.

However, during saving, I get the following error: Error using save: Error closing file dummy.mat

I thought it had to do with a lack of memory, but I've monitored the process during saving and I never run out of RAM, and I know that I have plenty of space left on my harddisk.

Does anyone know what causes this error?

Any suggestions are much appreciated!

  0 Comments

2 Answers

Answer by Jared
on 18 Oct 2011
 Accepted answer

Hi Bert,

I ran into the same error message a day or two ago with a struct filled with instances of classes that were similarly filled with lots of data. However, I could see in task manager that the memory use was in fact spiking.

The problem went away when I switched to version 7.3 format from version 7 (change file->preferences->general->MAT-Files or I think add flag '-v7.3' to save). This led me to believe that the memory problems might have had something to do with the form of compression done in mat files in version 7.

However, this does not solve another problem associated with save and load which might also cause some issues (it does for me). MATLAB uses lazy copying to conserve memory, i.e. A = B does not make a new copy of B until some part of A is later changed, e.g. perhaps A(end) = 1. Mat files appear to forget about all of these memory-saving relations, increasing both the size of the save files as well as the space required in memory once the save file is loaded.

Hope this helps! Jared

  2 Comments

Bert
on 18 Oct 2011

Hey Jared,

Indeed this turned out to be the problem. I figured this out a while ago but forgot to report it to the community.

I think it would be a valuable addition in the error message as a suggestion ('Maybe add -v7.3?'), because the user is pretty much left in the dark about the reasons of this error message.

Jesse Salazar
on 17 Jan 2015

Also worked for me. No issues thus far with the lazy copying. Bert, do you anticipate issues with data integrity? Or simply with redundancy/memory? For my purposes, as long as there is no issue with data integrity, I should be okay. Thanks for your post,

-J


Answer by Jonathan Pelham
on 17 Feb 2015

I have had a similar error message. This is a very old q&a. Does anyone know if the answer is still valid?

  0 Comments


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today