[FlopCpp] memory leaks

Tim Hultberg Tim.Hultberg at eumetsat.int
Sun May 20 16:06:52 EDT 2007


Hi, Paul

yes this one is just as easy as you say. I have fixed it now in
stable/1.0.

[if you find more easy ones, let me know :-)]

The remaining leaks (I am aware of) comes from some limitations in the
current implementation of MP_domain. I have a leak free implementation
of it in branches/experiment/experiment/New_domain.hpp but I have never
had the time to integrate it properly.

Cheers, Tim

Tim Hultberg

>>> "Paul Huang" <huangpaul99 at gmail.com> 05/18/07 9:33 PM >>>
Hi, Tim

I understand you know FlopC++ has quite a few memory leaks.  Some are
minor
but some are significant. After checking the source code, I assume,
based on
my limited understanding, some leaks are easy to fix. For example, in
mp_model.cpp, a pointer c is newed and passed to "Solver->loadProblem"
but
never released. Here is the code

---------------------------------------------------
c =  new double[n];
  for (int j=0; j<n; j++) {
    c[j] = 0.0;
  }
  for (size_t i=0; i<coefs.size(); i++) {
    int col = coefs[i].col;
    double elm = coefs[i].val;
    c[col] = elm;
  }

  // Column bounds
  for (int j=0; j<n; j++) {
    l[j] = 0.0;
    u[j] = inf;
  }

  for (varIt i=Variables.begin(); i!=Variables.end(); i++) {
    for (int k=0; k<(*i)->size(); k++) {
      l[(*i)->offset+k] = (*i)->lowerLimit.v[k];
      u[(*i)->offset+k] = (*i)->upperLimit.v[k];
    }
  }

  Solver->loadProblem(n, m, Cst, Rnr, Elm, l, u, c, bl, bu);
-----------------------------------------------

My question is,  is it just as easy as add "delete [] c" after calling
"Solver->loadProblem" and then the problem will be fixed, or it is not
as
easy as it looks and more complication is involved? If the former is
true,
then my second question is, when are you going to fix those easy-to-fix
leaks? :-)


Cheers
Paul



More information about the FlopCpp mailing list