<br><font size=2 face="sans-serif">Xavier,</font>
<br>
<br><font size=2 face="sans-serif">With your new example, I eventually
managed to get it to give me a memory leak with Clp/stable. &nbsp;The putative
leak is in Clp/trunk but is very unlikely to occur as the +-1 matrix is
switched off by default and can not easily be switched on using OsiClpSolverInterface.</font>
<br>
<br><font size=2 face="sans-serif">So I would switch to trunk. &nbsp;I
will fix leak anyway - but that will only be in trunk. &nbsp;If you need
a +-1 matrix for speed (and are not doing branch and cut) then you will
have to wait a day or two.</font>
<br>
<br><font size=2 face="sans-serif">John Forrest</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>&quot;xavier warin&quot;
&lt;xavier.warin@gmail.com&gt;</b> </font>
<br><font size=1 face="sans-serif">Sent by: coin-lpsolver-bounces@list.coin-or.org</font>
<p><font size=1 face="sans-serif">09/13/2007 07:24 AM</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">coin-lpsolver@list.coin-or.org</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td><font size=1 face="sans-serif">Olivier CORMIER &lt;olivier.cormier@edf.fr&gt;</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">[Coin-lpsolver] Re: Re: Memory leaks
(John J Forrest)</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=3>Dear John<br>
<br>
I agree on the small example i gave you. In fact i noticed yesterday that
i was perhaps linking against an old coin version.<br>
I crashed my whole installation and i installed Coin again.<br>
On the small example i gave you, no problem if you add the good delete.
<br>
On our own problem the problem is &nbsp;present on Linux and Windows.<br>
<br>
While doing optimization on the small following problem :<br>
<br>
 &nbsp;//// Interface de résolution COIN<br>
 &nbsp;boost::shared_ptr&lt;OsiSolverInterface&gt; bsi; <br>
 &nbsp;bsi = boost::shared_ptr&lt;OsiSolverInterface&gt; ( new OsiClpSolverInterface
);<br>
 &nbsp;<br>
 &nbsp;// nombre de dates d'exercices<br>
 &nbsp;int N = exerc.size() ;<br>
<br>
 &nbsp;// &nbsp;nombre de colonnes<br>
 &nbsp;int n_cols = 2*N ;<br>
<br>
 &nbsp;Array&lt;double,1&gt; bobjective(n_cols);<br>
 &nbsp;Array&lt;double,1&gt; bcol_lb(n_cols);<br>
 &nbsp;Array&lt;double,1&gt; bcol_ub(n_cols);<br>
<br>
 &nbsp;// fonction objectif<br>
 &nbsp;for (int i = 0 ; i &lt; N ; ++i)<br>
 &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp;bobjective(i) = &nbsp;- (future(i+1)- Cout_Tirage(i+1))*exp(-taux(i+1))*Duree(i+1)
; <br>
 &nbsp; &nbsp; &nbsp;bobjective(i+N) = (future(i+1) + Cout_Injection(i+1))*exp(-taux(i+1))*Duree(i+1);<br>
 &nbsp; &nbsp;}<br>
 &nbsp;for (int i = 0 ; i &lt; N ; ++i)<br>
 &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp;bcol_lb(i) = &nbsp;0.;<br>
 &nbsp; &nbsp; &nbsp;bcol_lb(i+N) = 0.;<br>
 &nbsp; &nbsp; &nbsp;bcol_ub(i) = Tirage(i+1); <br>
 &nbsp; &nbsp; &nbsp;bcol_ub(i+N) = &nbsp;Injection(i+1);<br>
 &nbsp; &nbsp;}<br>
 &nbsp; &nbsp; &nbsp;<br>
 <br>
 &nbsp;// pour la matrice des contraintes<br>
 &nbsp;int n_rows = N ;<br>
 &nbsp;<br>
 &nbsp;Array&lt;double,1&gt; brow_lb(n_rows);<br>
 &nbsp;Array&lt;double,1&gt; brow_ub(n_rows); <br>
 &nbsp; &nbsp; <br>
 &nbsp;// création matrice contrainte<br>
 &nbsp;Array&lt;int,1&gt; bligne(N*(N+1));<br>
 &nbsp;Array&lt;int,1&gt; bcolonne(N*(N+1));<br>
 &nbsp;Array&lt;double,1&gt; belement(N*(N+1));<br>
 &nbsp;int ielement = 0;<br>
<br>
 &nbsp;for (int j = 0 ; j &lt; N ; ++j) <br>
 &nbsp;{<br>
 &nbsp; &nbsp;brow_lb(j) = Stock_Min(j+2) -Stock_Init ;<br>
 &nbsp; &nbsp;brow_ub(j) = Stock_Max(j+2) -Stock_Init ;<br>
 &nbsp; &nbsp;for (int i = 0 &nbsp;; &nbsp; i &lt;= j &nbsp; ; ++i)<br>
 &nbsp; &nbsp; &nbsp;{<br>
 &nbsp; &nbsp;double d = 1.;<br>
 &nbsp; &nbsp;bcolonne(ielement) = i;<br>
 &nbsp; &nbsp;bligne(ielement) = j; <br>
 &nbsp; &nbsp;belement(ielement) = -d;<br>
 &nbsp; &nbsp;ielement++;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
 &nbsp; &nbsp;bcolonne(ielement) = i+N;<br>
 &nbsp; &nbsp;bligne(ielement) = j;<br>
 &nbsp; &nbsp;belement(ielement) = d;<br>
 &nbsp; &nbsp;ielement++;<br>
 &nbsp; &nbsp; &nbsp;}<br>
 &nbsp;}<br>
<br>
<br>
 &nbsp;bsi-&gt;loadProblem(CoinPackedMatrix(false, bligne.data(), bcolonne.data(),
belement.data(), ielement), <br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bcol_lb.data(), bcol_ub.data(), bobjective.data(),
brow_lb.data(), brow_ub.data());<br>
 &nbsp;<br>
 &nbsp;bsi-&gt;initialSolve();<br>
<br>
 &nbsp;// Check the solution <br>
 &nbsp;My_assert( bsi-&gt;isProvenOptimal() ) ;<br>
#if defined(BZ_DEBUG)<br>
 &nbsp;std::cout &lt;&lt; &quot;Found optimal solution!&quot; &lt;&lt;
std::endl; <br>
 &nbsp;std::cout &lt;&lt; &quot;Objective value bsi is &quot; &lt;&lt;
bsi-&gt;getObjValue() &lt;&lt; std::endl; <br>
#endif<br>
<br>
<br>
// &nbsp;const double *solution;<br>
 &nbsp;const double *bsolution;<br>
 &nbsp;bsolution = bsi-&gt;getColSolution();<br>
 &nbsp;// sortie Blitz des valeurs de tirages puis d'injection en chaque
date d'exercice<br>
 &nbsp;Array&lt;double,1&gt; sortie(n_cols, blitz::fortranArray);<br>
 &nbsp;for(int i = 1; i &lt;= n_cols; i++)<br>
 &nbsp; &nbsp;sortie(i) = bsolution[i-1] ; &nbsp; &nbsp;// stockage du
resultat<br>
<br>
There are leaks.<br>
Using valgrind we found that it is due to an allocation of a CoinPackedMatrix
in <br>
<br>
==29301== 1,560 bytes in 26 blocks are definitely lost in loss record 657
of 723<br>
==29301== &nbsp; &nbsp;at 0x401DB31: operator new(unsigned) (vg_replace_malloc.c:163)<br>
==29301== &nbsp; &nbsp;by 0x783B56B: ClpPlusMinusOneMatrix::getPackedMatrix()
const ( ClpPlusMinusOneMatrix.cpp:1049)<br>
==29301== &nbsp; &nbsp;by 0x77DBAF0: ClpModel::matrix() const (ClpModel.hpp:555)<br>
==29301== &nbsp; &nbsp;by 0x786144A: ClpSimplex::tightenPrimalBounds(double,
int) (ClpSimplex.cpp:3939)<br>
==29301== &nbsp; &nbsp;by 0x78ADAD1: ClpSimplex::initialSolve(ClpSolve&amp;)
( ClpSolve.cpp:856)<br>
==29301== &nbsp; &nbsp;by 0x77DB54F: OsiClpSolverInterface::initialSolve()
(OsiClpSolverInterface.cpp:274)<br>
<br>
This is due to the fact that there are 1. in the constraint matrix. In
this case we use &nbsp;ClpPLusMinusOneMatrix ::getPackedMatrix() with an
allocation. <br>
When we slightly shift the value to 1. + epsilon &nbsp;the problem disappear
because we don't construct this matrix anymore.<br>
<br>
I hope it will help you.<br>
Sincerely yours<br>
<br>
Xavier Warin</font><tt><font size=2>_______________________________________________<br>
Coin-lpsolver mailing list<br>
Coin-lpsolver@list.coin-or.org<br>
http://list.coin-or.org/mailman/listinfo/coin-lpsolver<br>
</font></tt>
<br>