[FlopCpp] memory leaks

Paul Huang huangpaul99 at gmail.com
Fri May 18 15:33:51 EDT 2007


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.coin-or.org/pipermail/flopcpp/attachments/20070518/7f576861/attachment.html


More information about the FlopCpp mailing list