[Ipopt] Memory leak in Matlab interface when using auxdata
Tony Kelman
kelman at berkeley.edu
Wed Aug 17 22:18:21 EDT 2011
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
More information about the Ipopt
mailing list