What might cause matlab to non-deterministically freeze up?

10 views (last 30 days)
Hello,
Thank you in advance for your help. I am running a very large job, and for some reason matlab keeps freezing up during its execution. Basically I am repeatedly calling the same function with different values and recording the results. The program is deterministic, that is, the same values are passed to my function in the same order each time I run the job. Therefore, if I have an infinite loop or some other kind of bug, any problem should be appear in the same spot each time I run the program.
When matlab freezes up, it is at different points in the execution of the function, and with different input values. Why might matlab be freezing up? I am keeping tabs on the progress of the job by printing how many times the function has executed to the console (it should execute the same number of times each time i run the job). Could this be causing matlab to freeze, or is possible that matlab has not frozen, but for what ever reason has stopped printing to the console?
It does not take very long for an individual function call to execute so I know after about 20 seconds of not seeing an update that matlab has frozen. One thing that I have noticed is that whenever matlab does freeze I will see this character "|" directly before, or there a bouts, the last line of output to the console. No where in my program is "|" printed to the console.
What could possibly be causing this?
  1 Comment
Star Strider
Star Strider on 13 Apr 2014
Depends on what you’re doing. Numerically integrating a differential equation with singularities or extreme values in its solution could cause this.
The Debugger is your friend here.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 13 Apr 2014
Perhaps it running out of memory. Not sure what you're doing but maybe at the end of each loop try to clear out memory with lines like
clear('var1', 'var2', 'var3');
cla reset; % Get rid of "piled up" images or whatever.
  4 Comments
Ryan
Ryan on 14 Apr 2014
I don't think so because, the amount of memory used by the program is very close to constant. The output of the function is a single integer value. In order for outside processes to be having an effect (I'm not running anything else) I would have to be very close to running out of memory and I really don't think that I'm any where near close enough.
Image Analyst
Image Analyst on 14 Apr 2014
The only thing I can think of is to print what you're doing and see where it locks up.
fprintf('About to run function 1...\n');
function1();
fprintf('About to run function 2...\n');
function2();
fprintf('About to run function 3...\n');
function3();
See if it hangs at the same place every time and then try to debug it further once you know where it's hanging.

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!