coin-or / coin-or/CyLP

Memory leak in CyClpSimplex

Open
#102 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
JetBrains MPS
Stars
192
Forks
70
PR merge metrics
No merged PRs in 30d

Description

I'm solving multiple LP problems stored in .mps files. Each problem has around 2000 variables and 1000 constraints, .mps file size is about 9 Mb. I've noticed that the memory is not released after `CyClpSimplex` goes out of scope.

Here is the minimal example to reproduce:

```python
import glob
from cylp.cy.CyClpSimplex import CyClpSimplex

for mps in glob.glob("./*.mps"):
CyClpSimplex().readMps(mps)
```

This leaks with about 4 Mb per problem. I.e. if I run this code on a directory with 3000 MPS files, the memory consumption goes up to about 12 Gb, even though I'm not even solving anything (and not even referring to `CyClpSimplex` from any variable)

This code which reuses the simplex object doesn't leak:

```python
import glob
from cylp.cy.CyClpSimplex import CyClpSimplex

c = CyClpSimplex()
for mps in glob.glob("./*.mps"):
c.readMps(mps)
```

I don't think that actual .mps files matter here, one can probably just use any MPS file of about the size I mentioned and just produce a couple of thousand of copies to reproduce the problem.

It looks like the workaround is easy: just reuse the `CyClpSimplex` object. But in reality, I'm not loading MPS files but building my models with `addVariable` and `addConstraint`, so I have to clean that model at the start of every loop iteration and I'm not sure how to do that reliably, without affecting future solutions.

Could you please either fix this issue or suggest a reliable workaround?

Thank you!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.