coin-or / Ipopt

COIN-OR Interior Point Optimizer IPOPT
https://coin-or.github.io/Ipopt
Other
1.4k stars 276 forks source link

Memory leak in Ipopt::Ma86SolverInterface #283

Closed svigerske closed 5 years ago

svigerske commented 5 years ago

Issue created by migration from Trac.

Original creator: mhahn

Original creation time: 2017-06-28 14:27:25

Assignee: ipopt-team

Version: 3.12

It appears that the member array order_ in the class Ipopt::Ma86SolverInterface is not being freed upon destruction of the solver interface. While not a major concern in single NLP solves, this appears to lead to a cumulative loss of free memory in applications where a large number of NLP solves must be performed (e.g. as relaxation solver in MINLP branch and bound).

To reproduce, build IPOPT (revision indicated in svn-info) after getting third party dependencies and configuring with the following arguments:

./configure --with-asl=BUILD --with-metis=BUILD --with-hsl=BUILD --with-mumps=BUILD --enable-debug

In this instance, BLAS and LAPACK are provided through the OS distribution (Ubuntu 17.04) and the HSL version is 2014.01.10.

Then, install IPOPT and dependencies to a prefix of your choice, and execute the following following command line to solve the problem described in the attached file batch.nl:

valgrind --tool=memcheck --leak-check=full ipopt batch.nl linear_solver=ma86 outlev=5

The expected output (mixed stdout/stderr) is attached in valgrind.log.

A possible fix is given in possible-fix.diff. It appears to get rid of the leak reported by valgrind. However, I have not verified whether there is a set of circumstances in which order_ == NULL when the destructor is invoked.

Attached are:

svigerske commented 5 years ago

Attachment batch.nl by mhahn created at 2017-06-28 14:28:02

Test problem file

svigerske commented 5 years ago

Attachment svn-info by mhahn created at 2017-06-28 14:28:38

Info about SVN revision in question

svigerske commented 5 years ago

Attachment valgrind.log by mhahn created at 2017-06-28 14:29:02

Valgrind output

svigerske commented 5 years ago

Attachment possible-fix.diff by mhahn created at 2017-06-28 14:29:53

Possible (but largely untested) fix

svigerske commented 5 years ago

Comment by @svigerske created at 2017-06-30 10:24:10

Thanks for finding this. This is now fixed in trunk 2c707bd4ea and should make it into the next release.

order_ can be NULL in the destructor, but a delete[] on a NULL pointer is ok (it just does nothing).

svigerske commented 5 years ago

Comment by @svigerske created at 2017-06-30 10:24:10

Resolution: fixed