[Coin-discuss] Possible memory leaks in CoinPreSolve when using CBC/CLP?

Kish Shen kish.shen at crosscoreop.com
Sat Jul 14 01:35:51 EDT 2007


 
Hi,

I have been using valgrind to try and track down some memory leaks in 
our program that uses CBC/CLP solver. Valgrind reports several instances 
of memory allocations that are then subsequently lost (I assume because 
it was not deleted) while my program call CbcModel's branchAndBound. 
They occur in two places:

==23118== 64 bytes in 4 blocks are definitely lost in loss record 83 of 127
==23118==    at 0x401CD4D: operator new[](unsigned) 
(vg_replace_malloc.c:195)
==23118==    by 0x82C469D: 
implied_free_action::presolve(CoinPresolveMatrix*, CoinPresolveAction 
const*, int&) (CoinPresolveImpliedFree.cpp:978)
==23118==    by 0x810C91B: ClpPresolve::presolve(CoinPresolveMatrix*) 
(ClpPresolve.cpp:543)
==23118==    by 0x81106C6: 
ClpPresolve::gutsOfPresolvedModel(ClpSimplex*, double, bool, int, bool, 
bool) (ClpPresolve.cpp:1505)
==23118==    by 0x810B8DA: ClpPresolve::presolvedModel(ClpSimplex&, 
double, bool, int, bool, bool) (ClpPresolve.cpp:101)
==23118==    by 0x805376A: OsiClpSolverInterface::resolve() 
(OsiClpSolverInterface.cpp:404)
==23118==    by 0x81D72A8: CbcModel::resolve(CbcNodeInfo*, int) 
(CbcModel.cpp:4890)
==23118==    by 0x81D4FD8: CbcModel::solveWithCuts(OsiCuts&, int, 
CbcNode*) (CbcModel.cpp:4194)
==23118==    by 0x81C6D19: CbcModel::branchAndBound(int) (CbcModel.cpp:1342)
==23118==    by 0x804CE2A: coin_branchAndBound(lp_desc*) (coinplex.cpp:451)
==23118==    by 0x804EDAE: coin_solve_problem (coinplex.cpp:1296)
==23118==    by 0x82DE948: step_1 (bug.c:473)

The call to new[]  in CoinPresolveImpliedFree.cpp:

      double *save_costs = nonzero_cost ? new double[hinrow[row]] : NULL;

and the second case:

==23118== 11,708 (208 direct, 11,500 indirect) bytes in 13 blocks are 
definitely lost in loss record 57 of 127
==23118==    at 0x401C8CF: operator new(unsigned) (vg_replace_malloc.c:163)
==23118==    by 0x82BBC3D: 
drop_empty_rows_action::presolve(CoinPresolveMatrix*, CoinPresolveAction 
const*) (CoinPresolveEmpty.cpp:432)
==23118==    by 0x810D0A5: ClpPresolve::presolve(CoinPresolveMatrix*) 
(ClpPresolve.cpp:726)
==23118==    by 0x81106C6: 
ClpPresolve::gutsOfPresolvedModel(ClpSimplex*, double, bool, int, bool, 
bool) (ClpPresolve.cpp:1505)
==23118==    by 0x810B8DA: ClpPresolve::presolvedModel(ClpSimplex&, 
double, bool, int, bool, bool) (ClpPresolve.cpp:101)
==23118==    by 0x805376A: OsiClpSolverInterface::resolve() 
(OsiClpSolverInterface.cpp:404)
==23118==    by 0x81D72A8: CbcModel::resolve(CbcNodeInfo*, int) 
(CbcModel.cpp:4890)
==23118==    by 0x81D4FD8: CbcModel::solveWithCuts(OsiCuts&, int, 
CbcNode*) (CbcModel.cpp:4194)
==23118==    by 0x81C6D19: CbcModel::branchAndBound(int) (CbcModel.cpp:1342)
==23118==    by 0x804CE2A: coin_branchAndBound(lp_desc*) (coinplex.cpp:451)
==23118==    by 0x804EDAE: coin_solve_problem (coinplex.cpp:1296)
==23118==    by 0x82DE948: step_1 (bug.c:473)
==23118==

and the call to new in CoinPresolveEmptycpp is:

    return (new drop_empty_rows_action(nactions, actions, next));

--------------------------------
As far as I can tell, both these cases are internal data structures 
allocated in the call to branchAndBound, so they are not problems with 
my own code's memory management, or have I missed something important?

I am using the trunk branch of Cbc, downloaded June 14.

I can send the program that generated these memory leaks if needed.
.
Thanks and cheers,

Kish Shen



More information about the Coin-discuss mailing list