MATLAB Answers

Jim Riggs
0

Why does this data file cause Matlab to lock-up?

Asked by Jim Riggs
on 11 Oct 2018
Latest activity Commented on by Jim Riggs
on 12 Oct 2018
I just spent the day trying to figure out why Matlab was locking up and not responding. It turns out that deleting a large data file solved the problem, but I am wondering if anyone can explain what is happening.
Here is the series of events:
I was running some simulations and collecting data in data structures in the Matlab base workspace. After a while, I notice that Matlab is slowing down, and I figure that it is getting low on resources, since these data structures are quite large. So, I attempt to save the data and figure out how I can reduce the size of the simulation output. I type the command:
save ('TrajData.m' , 'Struct1', 'Struct2', ...)
(there are a total of 6 or 8 data structures) At this point, Matlab locked up. (I immediately noticed that I specified '.m' rather than '.mat', so I am wondering if this had any impact on what happened.) Now Matlab is hung up, and will not respond. I don't even have access to the task manager on this system, so the only way I can kill the process is by restarting the computer. At this point, when I restart Matlab, it immediately hangs up while the status bar says "initializing...". Once again, it is completely non-responsive. After much fumbling around, I discover that deleting all of the files in the Matlab folder allows the program to start and run normally. As I am copying my original files back to the Matlab folder (with the Matlab window open), as soon as I copy the TrajData.m file, Matlab hangs up and throws a full screen of red error text, something to the effect of "out of memory". The TrajData.m file is just over 1GB in size. I am running Matlab R2015b, (the same occurs with 2016b) on a windows NT6.2 system with 8GB ram.
So, why does Matlab immediately lock-up when this file is copied to the Matlab folder?

  1 Comment

Well I guess when you mess with mfile MATLAB detects the source file changes and try to parse, consider the data is a garbage code, so just behave strangely.
Still the phenomenon looks odd to me and I don't have any desire of making any experiment with it.

Sign in to comment.

1 Answer

Answer by Kelly Kearney
on 12 Oct 2018

This is just a guess, but... Did you have a script named TrajData.m open in the editor at the time you first made the typo? Matlab saves a lot of info about your workspace setup when it closes (even if it closes in a less than graceful way, as in your case), and tries to restore things the same way when it reopens. So perhaps on startup it's trying to reopen the errant .m file in the Editor?

  4 Comments

Show 1 older comment
MATLAB scan pathdef yes. Not sure when and how often though.
" Do you think that Matlab "scans" all of the .m files in the folder, even when they are not being referenced by a current process?"
Yes, it does (this is one of the reasons why using absolute filenames is faster than using cd).
"..as soon as I copy the TrajData.m file, Matlab hangs up and throws a full screen of red error text"
Given that trajData.m is not a valid Mfile, this is no surprise. I guess cached files get checked and reloaded by MATLAB, and your totally messed up .m file is beyond anything it can cope with.
Thanks for your comments.

Sign in to comment.