[CoinMp] CoinMP cbc memory leak?

Rod Frowd rod at frowd.net
Wed Feb 1 00:08:01 EST 2012


Hi

I have been running CoinMP under valgrind and it is picking up a memory 
leak:

==9402== 9,028 (1,920 direct, 7,108 indirect) bytes in 2 blocks are 
definitely lost in loss record 40 of 40
==9402==    at 0x4C28B35: operator new(unsigned long) 
(vg_replace_malloc.c:261)
==9402==    by 0x4E3A321: CbcCreateSolverObject() (in 
/usr/local/lib/libCoinMP.so.0)
==9402==    by 0x4E3CA55: CbcOptimizeProblem (in 
/usr/local/lib/libCoinMP.so.0)

I looked at the code and for some reason the delete of the osi object 
has been commented out in the free routine:

HCBC CbcCreateSolverObject(void)
{
         PCBC pCbc;

         pCbc = (PCBC)malloc(sizeof(CBCINFO));
         if (!pCbc) {
                 return NULL;
         }
         memset(pCbc, 0, sizeof(CBCINFO));

         pCbc->clp = new ClpSimplex();
         pCbc->clp_presolve = new ClpSolve();
         pCbc->osi = new OsiClpSolverInterface(pCbc->clp);
         pCbc->cbc = NULL;  /* ERRORFIX 2/22/05: Crashes if not NULL 
when trying to set message handler */

         pCbc->msghandler = NULL;
         pCbc->iterhandler = NULL;
         pCbc->nodehandler = NULL;
         return (HCBC)pCbc;
}


void CbcClearSolverObject(HCBC hCbc)
{
         PCBC pCbc = (PCBC)hCbc;
         if (!pCbc) {
                 return;
         }
         if (pCbc->clp) delete pCbc->clp;
         if (pCbc->clp_presolve) delete pCbc->clp_presolve;
         //if (pCbc->osi) delete pCbc->osi;
         if (pCbc->cbc) delete pCbc->cbc;

         if (pCbc->msghandler)   delete pCbc->msghandler;
         if (pCbc->iterhandler)  delete pCbc->iterhandler;
         if (pCbc->nodehandler)  delete pCbc->nodehandler;

         free(pCbc);
}

Does anyone know why this was commented out?

It is not a big memory leak, but I am going to be doing thousands of 
MonteCarlo iterations and I need this to run tight and clean.

Rod Frowd







More information about the CoinMp mailing list