Unexpected Standard exception from MEX file. What() is:bad allocation

1,561 views
Skip to first unread message

Antoine Falisse

unread,
Oct 25, 2017, 9:12:45 AM10/25/17
to CasADi
Hello,

I am trying to solve optimal control problems with CasADi (v3.2.3) using direct collocation (IPOPT and MUMPS (default)). I use the MATLAB API and call an external function.
I have got the error message below. I was running two problems (calling the same external function) at the same time in MATLAB2016b and they returned the same error after 10503 and 13362 iterations, respectively. All that happened on a remote desktop so I don't know if the errors were returned at the same time (in that latter case, that would probably mean that something happened on the computer). I was wondering if you had an explanation for that error. This would help to start debugging.

Many thanks in advance,

Antoine

Unexpected Standard exception from MEX file.
What() is:bad allocation
..

Error in casadi.Function/call (line 738)
      [varargout{1:nargout}] = casadiMEX(796, self, varargin{:});

Error in casadi.Function/paren (line 1339)
        res = self.call(arg);

Error in casadi.Function/subsref (line 1324)
        [varargout{1:nargout}]= paren(self, s.subs{:});

Error in OCP_noreflex2010_delayLagPol_PCu_tf5_MPol_IG_sc_9mus_1p (line 770)
sol = solver('x0', w0, 'lbx', lbw, 'ubx', ubw,...

Joris Gillis

unread,
Oct 25, 2017, 9:21:19 AM10/25/17
to CasADi
Hi Antoine,

This error is typically raised when out-of-memory.
Perhaps the external function has a memory leak?
How does the memory usage grow over the iterations?

Best regards,
  Joris

Antoine Falisse

unread,
Oct 25, 2017, 9:49:59 AM10/25/17
to CasADi
Hi Joris,

Thanks for the quick reply.
When looking at the memory usage in the task manager, it seems relatively constant so I don't think there is a leak.
However, I just noticed that the remote desktop I was using had only 4GB of memory and running one problem uses about 1.8-1.9 GB so it could be that it went out of memory when running two problems at the same time.
I will try again running one problem only and see if it happens again.

Thanks
Reply all
Reply to author
Forward
0 new messages