Batch file crashes after processing few files only
Show older comments
I wrote a script to process 1000+ data files. The script does a multitude of things:
- loads .MF4 file (about 900 MB each)
- Does some processing
- generates multiple graphs
- Saves graphs to PNG files
The way I process my data is as follows:
- Develop script that automates file loading, data processing, and graphs generation
- Run the script overnight
- The next morning, simply insert the graphs in apowerpoint
The script used to run fine, and each loop takes about 25-30 seconds. Lately however, after 60 or so loops, the script crashes for no apparent reason. Some loops now take over 1000 sec. (I echo back to the screen the loop duration with the tic/toc function)
All files are essentially similar with no major differences, except fror slight variation in time duration (those are time traces)
I tried few things:
- Data files on the laptop's internal storage
- Data files on an external SSD (Thunderbolt), very fast
All options I tried so far failed. Any clue as to why the code is failing now? What diagnostics 'indicators' can I include to help diagnose .... such as available memory and the like. I thought of copying the SAME file multiple times (yet give it different names), and see precisely at which loop the code failes and whether it always fails at the same loop index.
Again, the code was running fine few days ago, and no clue what has happened.
PS. I'm using Matlab R2024b.
3 Comments
Matt J
1 minute ago
What diagnostics 'indicators' can I include to help diagnose
The error messages.
Catalytic
4 minutes ago
Does the failure happen if you re-run with the exact set of files you originally processed? Usually, if code magically stops working, it is because the input you are feeding it is improper in some way.
Star Strider
about 1 hour ago
One option to see what the problem is would be to save relevant diagnostic information (you decide what that is) to a .mat file in each iteration. That might include lasterror or MException.last to capture the last error. (This requires loading the .mat file each time, appending new data to it, and then saving it again. This will slow your code, however it could give you the information you need. That might not include information on the file causing the problem, however it will include everything up to it.)
Answers (1)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!