#274 Memory Leak on 64-bit Linux: with solution

closed-accepted
nobody
bowtie (178)
5
2013-02-28
2013-01-31
bertcarnell
No

I found a memory leak in Bowtie2-2.0.5 (and I did not see a change in these sources for Bowtie2-2.0.6) using valgrind on 64bit Linux. Patches are attached that eliminate the memory leaks.

This is the command I ran on the debug build of bowtie2 (make clean; make both-debug): valgrind --leak-check=yes ./bowtie2-align-debug -x lambda_virus -U ./example/reads/reads_1.fq -S eg1.sam &

This is a truncated version of the valgrind output.
==23553== Memcheck, a memory error detector
==23553== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==23553== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==23553== Command: ./bowtie2-align -x lambda_virus -U ./example/reads/reads_1.fq -S eg1.sam
==23553== Parent PID: 20513
==23553==
==23553==
==23553== HEAP SUMMARY:
==23553== in use at exit: 12,933,707 bytes in 50 blocks
==23553== total heap usage: 431,766 allocs, 431,716 frees, 843,482,496 bytes allocated
==23553==
==23553== 32 bytes in 1 blocks are definitely lost in loss record 2 of 26
==23553== at 0x51C85BA: operator new[](unsigned long) (vg_replace_malloc.c:264)
==23553== by 0x5114E6: EList_m128i::alloc(unsigned long) (sse_util.h:220)
==23553== by 0x511792: EList_m128i::lazyInit() (sse_util.h:200)
==23553== by 0x526186: EList_m128i::resize(unsigned long) (sse_util.h:90)
==23553== by 0x5264C8: Checkpointer::init(unsigned long, unsigned long, unsigned long, long, bool, bool, bool, bool) (sse_util.h:383)
==23553== by 0x54D245: SwAligner::alignGatherEE8(int&, bool) (aligner_swsse_ee_u8.cpp:350)
==23553== by 0x4AFB30: SwAligner::align(RandomSource&, long&) (aligner_sw.cpp:504)
==23553== by 0x4C64D8: SwDriver::extendSeeds(Read&, bool, SeedResults&, Ebwt const&, Ebwt const*, BitPairReference const&, SwAligner&, Scoring const&, int, int, int, long&, int, unsigned long, bool, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, bool, bool, unsigned long, unsigned long, bool, int, AlignmentCacheIface&, RandomSource&, WalkMetrics&, SwMetrics&, PerReadMetrics&, AlnSinkWrap*, bool, bool&) (aligner_sw_driver.cpp:1125)
==23553== by 0x4121D6: multiseedSearchWorker(void*) (bt2_search.cpp:3683)
==23553== by 0x4161A9: multiseedSearch(Scoring&, PairedPatternSource&, AlnSink&, Ebwt&, Ebwt&, OutFileBuf*) (bt2_search.cpp:4210)
==23553== by 0x41796E: void driver<SString<char> >(char const*, std::string const&, std::string const&) (bt2_search.cpp:4463)
==23553== by 0x418A8B: bowtie (bt2_search.cpp:4624)

[SNIP]

==23553==
==23553== 270,787 (270,584 direct, 203 indirect) bytes in 1 blocks are definitely lost in loss record 19 of 26
==23553== at 0x51C895E: operator new(unsigned long) (vg_replace_malloc.c:220)
==23553== by 0x470AFC: PatternSource::patsrcFromStrings(PatternParams const&, EList<std::string, 128> const&) (pat.cpp:45)
==23553== by 0x47185C: PairedPatternSource::setupPatternSources(EList<std::string, 128> const&, EList<std::string, 128> const&, EList<std::string, 128> const&, EList<std::string, 128> const&, EList<std::string, 128> const&, EList<std::string, 128> const&, EList<std::string, 128> const&, PatternParams const&, bool) (pat.cpp:392)
==23553== by 0x4165E2: void driver<SString<char> >(char const*, std::string const&, std::string const&) (bt2_search.cpp:4267)
==23553== by 0x418A8B: bowtie (bt2_search.cpp:4624)
==23553== by 0x55D851: main (bowtie_main.cpp:67)
==23553==

[SNIP]

==23553==
==23553== LEAK SUMMARY:
==23553== definitely lost: 6,116,712 bytes in 42 blocks
==23553== indirectly lost: 2,097,627 bytes in 4 blocks
==23553== possibly lost: 4,718,800 bytes in 3 blocks
==23553== still reachable: 568 bytes in 1 blocks
==23553== suppressed: 0 bytes in 0 blocks
==23553== Reachable blocks (those to which a pointer was found) are not shown.
==23553== To see them, rerun with: --leak-check=full --show-reachable=yes
==23553==
==23553== For counts of detected and suppressed errors, rerun with: -v
==23553== ERROR SUMMARY: 21 errors from 21 contexts (suppressed: 4 from 4)

After the attached patches are applied. The memory leaks are gone

==25920== Memcheck, a memory error detector
==25920== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==25920== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==25920== Command: ./bowtie2-align-debug -x lambda_virus -U ./example/reads/reads_1.fq -S eg1.sam
==25920== Parent PID: 24656
==25920==
==25920==
==25920== HEAP SUMMARY:
==25920== in use at exit: 0 bytes in 0 blocks
==25920== total heap usage: 431,765 allocs, 431,765 frees, 843,482,399 bytes allocated
==25920==
==25920== All heap blocks were freed -- no leaks are possible
==25920==
==25920== For counts of detected and suppressed errors, rerun with: -v
==25920== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)

Discussion

  • bertcarnell

    bertcarnell - 2013-01-31

    Patches to pat.h and sse_util.h

     
  • Val

    Val - 2013-02-28
    • status: open --> closed-accepted
     
  • Val

    Val - 2013-02-28

    Hi,

    Thank you for your great input! We knew about this issue for a while but we were unable to prioritize a fix until now. This issue will be fixed in the upcoming release.

    Thanks again for your feedback and for using bowtie2,
    Val

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks