tags:

views:

157

answers:

2

I have a matlab script, that every now and them produces the message:

Caught std::exception Exception message is:
bad allocation
Unexpected error status flag encountered.  Resetting to proper state.

What could be causing this?

+1  A: 

My best guess is that your script is trying to allocate some memory and failing. The occurrence of such an error will depend on the availability of memory on your computer at the time allocation is attempted. The available memory will vary according to what is going on at the time in other programs, the operating system, even the state of your Matlab session.

For a more accurate diagnosis, you'll have to tell us more, maybe even post your script.

High Performance Mark
+2  A: 

This is a bug in MATLAB, in which some part of MATLAB is not handling a std::bad_alloc exception correctly (std::bad_alloc is an out-of-memory exception thrown from the C++ runtime library).

The "Unexpected error status flag encountered. Resetting to proper state." is an internal diagnostic - you shouldn't see it unless MATLAB has gotten into a bad state, which in this case is happening because it's encountering the bad_alloc someplace where it was not expected. Recent versions of MATLAB have fixed most of these issues, except in extremely low-memory situations (like, there's less than 1 kilobyte of free memory left). What version are you using?

SCFrench
using version 7.7.0.471 sorry for taking so long to answer you
noam

related questions