[Ipopt] Memory leak in Matlab interface when using auxdata

Peter Carbonetto pcarbo at uchicago.edu
Thu Aug 18 15:15:51 EDT 2011

Hi Tony,

    It definitely looks like there is a bug in the MATLAB interface. I'll 
have a look as soon as I get a chance---hopefully sometime early next 
week. I'm glad you found a workaround for now.

Peter Carbonetto, Ph.D.
Postdoctoral Fellow
Dept. of Human Genetics
University of Chicago

On Wed, 17 Aug 2011, Tony Kelman wrote:

> I apologize if this has already been solved, I'm not sure when the win32
> version of the Matlab interface I'm using was compiled.
> My current optimization problem happens to use a large auxdata structure
> (about 6 mb according to whos), and when I run the Matlab interface using
> the following setup:
> funcs.objective = @objective;
> funcs.gradient = @grad;
> funcs.constraints = @constraints;
> funcs.jacobian = @jacobian;
> funcs.jacobianstructure = @jacobianstructure;
> options.auxdata = auxdata;
> I see the memory usage of Matlab.exe start ramping up with every Ipopt
> iteration until it uses all the memory on my machine, then the iterations
> slow to a crawl until I kill Matlab.
> If, on the other hand, I use the following workaround:
> funcs.objective = @(x) objective(x, auxdata);
> funcs.gradient = @(x) grad(x, auxdata);
> funcs.constraints = @(x) constraints(x, auxdata);
> funcs.jacobian = @(x) jacobian(x, auxdata);
> funcs.jacobianstructure = @() jacobianstructure(auxdata);
> and leave options.auxdata undefined, then everything works as expected, no
> apparent memory leaks. I don't know whether this workaround imposes extra
> overhead costs from Matlab's handling of anonymous functions and
> associated workspaces. I've been meaning to compare this to other possible
> workarounds like global variables (although I dislike the thought of
> global variables on principle).
> This is counterintuitive, isn't auxdata supposed to never change? Is it
> being loaded and duplicated in memory at every iteration without being
> cleared/freed? Again please let me know if this has already been fixed. If
> not, you should hopefully be able to replicate the behavior with a big
> dummy auxdata like zeros(1000).
> Thanks,
> Tony Kelman
> _______________________________________________
> Ipopt mailing list
> Ipopt at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/ipopt

More information about the Ipopt mailing list