Hello everyone,<div><br></div><div>Using valgrind I found a bunch of memory leaks with the Sparse Jacobian features in ADOL-C. I noticed in the mailing list archives this problem has been previously reported; The leaks still persist after I upgraded to ADOL-C 2.2.0 and ColPack 1.0.3 today (the recommended action).</div>

<div><br></div><div>Below is an excerpt of the valgrind report.</div><div><br></div><div><div>==21732== </div><div>==21732== HEAP SUMMARY:</div><div>==21732==     in use at exit: 29,627,156 bytes in 157,000 blocks</div><div>

==21732==   total heap usage: 229,529,359 allocs, 229,372,359 frees, 762,459,196,535 bytes allocated</div><div>==21732== </div><div>==21732== 45 bytes in 1 blocks are possibly lost in loss record 2 of 105</div><div>==21732==    at 0x4C28B42: operator new(unsigned long) (vg_replace_malloc.c:261)</div>

<div>==21732==    by 0x5413E6C: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator&lt;char&gt; const&amp;) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.14)</div><div>==21732==    by 0x5415904: char* std::string::_S_construct&lt;char const*&gt;(char const*, char const*, std::allocator&lt;char&gt; const&amp;, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.14)</div>

<div>==21732==    by 0x5415DF1: std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::basic_string(char const*, std::allocator&lt;char&gt; const&amp;) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.14)</div>

<div>==21732==    by 0x4C3DEF: ColPack::BipartiteGraphPartialOrdering::ColumnSmallestLastOrdering() (in /home/awdowlin/Documents/svn/research/ssPowerOptimTightBounds/debug)</div><div>==21732==    by 0x4C4BB7: ColPack::BipartiteGraphPartialOrdering::OrderVertices(std::string, std::string) (in /home/awdowlin/Documents/svn/research/ssPowerOptimTightBounds/debug)</div>

<div>==21732==    by 0x47BEC8: ColPack::BipartiteGraphPartialColoringInterface::PartialDistanceTwoColoring(std::string, std::string) (in /home/awdowlin/Documents/svn/research/ssPowerOptimTightBounds/debug)</div><div>==21732==    by 0x47C9B3: ColPack::BipartiteGraphPartialColoringInterface::GenerateSeedJacobian(double***, int*, int*, std::string, std::string) (in /home/awdowlin/Documents/svn/research/ssPowerOptimTightBounds/debug)</div>

<div>==21732==    by 0x516721A: sparse_jac (sparsedrivers.cpp:314)</div><div>==21732==    by 0x411BE5: Jac(int, double, _generic_N_Vector*, _generic_N_Vector*, _DlsMat*, void*, _generic_N_Vector*, _generic_N_Vector*, _generic_N_Vector*) (ss_model.c:364)</div>

<div>==21732==    by 0x47606D: cvDenseSetup (cvodes_dense.c:269)</div><div>==21732==    by 0x466228: cvStgrNlsNewton (cvodes.c:6561)</div><div>==21732== </div><div>==21732== 48 bytes in 1 blocks are possibly lost in loss record 3 of 105</div>

<div>==21732==    at 0x4C28FAC: malloc (vg_replace_malloc.c:236)</div><div>==21732==    by 0x515A679: indopro_forward_safe (uni5_for.c:1341)</div><div>==21732==    by 0x5166016: jac_pat (sparsedrivers.cpp:91)</div><div>==21732==    by 0x51670BF: sparse_jac (sparsedrivers.cpp:268)</div>

<div>==21732==    by 0x411BE5: Jac(int, double, _generic_N_Vector*, _generic_N_Vector*, _DlsMat*, void*, _generic_N_Vector*, _generic_N_Vector*, _generic_N_Vector*) (ss_model.c:364)</div><div>==21732==    by 0x47606D: cvDenseSetup (cvodes_dense.c:269)</div>

<div>==21732==    by 0x465C10: cvNlsNewton (cvodes.c:6117)</div><div>==21732==    by 0x467D88: cvStep (cvodes.c:5873)</div><div>==21732==    by 0x469EA9: CVode (cvodes.c:3029)</div><div>==21732==    by 0x41442E: eval_f_c(double*, double*, double*) (ss_model.c:207)</div>

<div>==21732==    by 0x4117BA: main (ssnew.c:146)</div><div>==21732== </div><div>==21732== 52 bytes in 1 blocks are possibly lost in loss record 4 of 105</div><div>==21732==    at 0x4C28B42: operator new(unsigned long) (vg_replace_malloc.c:261)</div>

<div>==21732==    by 0x5413E6C: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator&lt;char&gt; const&amp;) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.14)</div><div>==21732==    by 0x5415904: char* std::string::_S_construct&lt;char const*&gt;(char const*, char const*, std::allocator&lt;char&gt; const&amp;, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.14)</div>

<div>==21732==    by 0x5415DF1: std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::basic_string(char const*, std::allocator&lt;char&gt; const&amp;) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.14)</div>

<div>==21732==    by 0x4C7FE6: ColPack::BipartiteGraphPartialColoring::PartialDistanceTwoColumnColoring() (in /home/awdowlin/Documents/svn/research/ssPowerOptimTightBounds/debug)</div><div>==21732==    by 0x47C0D7: ColPack::BipartiteGraphPartialColoringInterface::PartialDistanceTwoColoring(std::string, std::string) (in /home/awdowlin/Documents/svn/research/ssPowerOptimTightBounds/debug)</div>

<div>==21732==    by 0x47C9B3: ColPack::BipartiteGraphPartialColoringInterface::GenerateSeedJacobian(double***, int*, int*, std::string, std::string) (in /home/awdowlin/Documents/svn/research/ssPowerOptimTightBounds/debug)</div>

<div>==21732==    by 0x516721A: sparse_jac (sparsedrivers.cpp:314)</div><div>==21732==    by 0x411BE5: Jac(int, double, _generic_N_Vector*, _generic_N_Vector*, _DlsMat*, void*, _generic_N_Vector*, _generic_N_Vector*, _generic_N_Vector*) (ss_model.c:364)</div>

<div>==21732==    by 0x47606D: cvDenseSetup (cvodes_dense.c:269)</div><div>==21732==    by 0x466228: cvStgrNlsNewton (cvodes.c:6561)</div><div>==21732==    by 0x46979C: cvStep (cvodes.c:6406)</div></div><div><br></div><div>

Note: Errors 5 through 105 are virtually the same.</div><div><br></div><div><div>==21732== 4,838,562 (95,232 direct, 4,743,330 indirect) bytes in 186 blocks are definitely lost in loss record 105 of 105</div><div>==21732==    at 0x4C28B42: operator new(unsigned long) (vg_replace_malloc.c:261)</div>

<div>==21732==    by 0x516715C: sparse_jac (sparsedrivers.cpp:302)</div><div>==21732==    by 0x411BE5: Jac(int, double, _generic_N_Vector*, _generic_N_Vector*, _DlsMat*, void*, _generic_N_Vector*, _generic_N_Vector*, _generic_N_Vector*) (ss_model.c:364)</div>

<div>==21732==    by 0x47606D: cvDenseSetup (cvodes_dense.c:269)</div><div>==21732==    by 0x465C10: cvNlsNewton (cvodes.c:6117)</div><div>==21732==    by 0x467D88: cvStep (cvodes.c:5873)</div><div>==21732==    by 0x469EA9: CVode (cvodes.c:3029)</div>

<div>==21732==    by 0x41442E: eval_f_c(double*, double*, double*) (ss_model.c:207)</div><div>==21732==    by 0x4117BA: main (ssnew.c:146)</div><div>==21732== </div><div>==21732== LEAK SUMMARY:</div><div>==21732==    definitely lost: 2,101,704 bytes in 3,135 blocks</div>

<div>==21732==    indirectly lost: 27,442,563 bytes in 153,610 blocks</div><div>==21732==      possibly lost: 35,785 bytes in 6 blocks</div><div>==21732==    still reachable: 47,104 bytes in 249 blocks</div><div>==21732==         suppressed: 0 bytes in 0 blocks</div>

<div>==21732== Reachable blocks (those to which a pointer was found) are not shown.</div><div>==21732== To see them, rerun with: --leak-check=full --show-reachable=yes</div></div><div><br></div><div>main, eval_f_c and Jac all refer to function I (or my predecessor) have written. The functions beginning with cv belong to the numeric integrator CVODES. ADOL-C is called in the function Jac.</div>

<div><br></div><div>Are there any recommendations on resolving this issue? I&#39;m happy to help, but my C/C++ is a bit rusty.</div><div><br></div><div>Alex Dowling</div><div><br></div>