From rod at frowd.net Wed Feb 1 00:08:01 2012 From: rod at frowd.net (Rod Frowd) Date: Wed, 01 Feb 2012 15:08:01 +1000 Subject: [CoinMp] CoinMP cbc memory leak? Message-ID: <4F28C8B1.7070502@frowd.net> 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