[ADOL-C] sparse_jacobian.cpp

Brad Bell bradbell at seanet.com
Wed Mar 4 09:33:23 EST 2020


I think I have found the problem, or at least the sed command below fixes the memory leak for the 
testing I have done:

git clone https://gitlab.com/adol-c/adol-c.git adolc.git
cd adolc.git
git checkout v2.6.3
sed -i 'ADOL-C/src/fo_rev.c' \
     -e 's|^    myfree2(rpp_A);|    free(rpp_A[0]);\n&|'





On 2/24/20 8:56 AM, Brad Bell wrote:
> I am running some speed tests that repeatedly (many time) execute ADOL-C sparse Jacobian 
> calculations and have been running out of memory.
>
> While using valgrind  to help tack this down I got the output below for the sparse_jacobian 
> program example; to be specific,
>     ADOL-C/examples/additional_examples/sparse/sparse_jacobian.cpp
> Can anyone else reproduce this ?
>
> sparse>valgrind  --leak-check=full --show-leak-kinds=all ./sparse_jacobian
> ==674990== Memcheck, a memory error detector
> ==674990== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
> ==674990== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
> ==674990== Command: ./sparse_jacobian
> ==674990==
>
>  c =   -1.123533e+00  1.128761e+00  5.906196e+00
>  J
>
>  0:      2.0000      1.0000      0.0000     -0.9823     -0.0071 0.0000
>  1:      0.0000      0.0000      2.1972      2.7726      0.0000 0.0000
>  2:      0.0000      0.0000      0.0000      0.0000      3.6428 3.2721
>
> ... snip ...
>
> ==674990==
> ==674990== HEAP SUMMARY:
> ==674990==     in use at exit: 2,704 bytes in 7 blocks
> ==674990==   total heap usage: 438 allocs, 431 frees, 32,086,422 bytes allocated
> ==674990==
> ==674990== 256 bytes in 1 blocks are definitely lost in loss record 1 of 7
> ==674990==    at 0x483880B: malloc (vg_replace_malloc.c:309)
> ==674990==    by 0x44A89A: fov_reverse (fo_rev.c:507)
> ==674990==    by 0x426998: sparse_jac (sparsedrivers.cpp:402)
> ==674990==    by 0x403B5C: main (sparse_jacobian.cpp:107)
>
> ... snip ...
>
> ==674990== LEAK SUMMARY:
> ==674990==    definitely lost: 1,920 bytes in 6 blocks
> ==674990==    indirectly lost: 0 bytes in 0 blocks
> ==674990==      possibly lost: 0 bytes in 0 blocks
> ==674990==    still reachable: 784 bytes in 1 blocks
> ==674990==         suppressed: 0 bytes in 0 blocks
> ==674990==
> ==674990== For lists of detected and suppressed errors, rerun with: -s
> ==674990== ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)
>
> The config.log file contains:
> configure:3635: result: g++
> configure:3662: checking for C++ compiler version
> configure:3671: g++ --version >&5
> g++ (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1)
>
>
> The version of valgrind is given by
> sparse>valgrind --version
> valgrind-3.15.0
>
>
> P.S.
> Where can I find specifications for the sparse_jac routine ?
> Looking at sparsedrivers.cpp, it seems that if *rind, *cind, and *values are all not null on 
> input, they are used and not re-allocated (under the assumption that the sparsity pattern has not 
> changed since the previous call) ?
> It seems that in jacobian_example.cpp, they are freed and reallocated for every call.
>



More information about the ADOL-C mailing list