torognes / swarm

A robust and fast clustering method for amplicon-based studies
GNU Affero General Public License v3.0
123 stars 23 forks source link

minor unfreed memory allocation (all swarm versions) #126

Closed frederic-mahe closed 5 years ago

frederic-mahe commented 5 years ago

That seems to be the only unfreed memory allocation. It appears when running swarm with the options -v, -h, or -i:

valgrind --leak-check=full --show-leak-kinds=all swarm -v                                                                                                                                                         
==19979== Memcheck, a memory error detector
==19979== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==19979== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
==19979== Command: swarm -v
==19979==
Swarm 2.2.2 [Jan 21 2019 21:27:19]
Copyright (C) 2012-2019 Torbjorn Rognes and Frederic Mahe
https://github.com/torognes/swarm

Mahe F, Rognes T, Quince C, de Vargas C, Dunthorn M (2014)
Swarm: robust and fast clustering method for amplicon-based studies
PeerJ 2:e593 https://doi.org/10.7717/peerj.593

Mahe F, Rognes T, Quince C, de Vargas C, Dunthorn M (2015)
Swarm v2: highly-scalable and high-resolution amplicon clustering
PeerJ 3:e1420 https://doi.org/10.7717/peerj.1420

==19979==
==19979== HEAP SUMMARY:
==19979==     in use at exit: 552 bytes in 1 blocks
==19979==   total heap usage: 2 allocs, 1 frees, 73,256 bytes allocated
==19979==
==19979== 552 bytes in 1 blocks are still reachable in loss record 1 of 1
==19979==    at 0x4C2BBAF: malloc (vg_replace_malloc.c:299)
==19979==    by 0x595955C: __fopen_internal (iofopen.c:69)
==19979==    by 0x10B189: args_init(int, char**) (swarm.cc:571)
==19979==    by 0x109A47: main (swarm.cc:631)
==19979==
==19979== LEAK SUMMARY:
==19979==    definitely lost: 0 bytes in 0 blocks
==19979==    indirectly lost: 0 bytes in 0 blocks
==19979==      possibly lost: 0 bytes in 0 blocks
==19979==    still reachable: 552 bytes in 1 blocks
==19979==         suppressed: 0 bytes in 0 blocks
==19979==
==19979== For counts of detected and suppressed errors, rerun with: -v
==19979== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

The allocation seems to be done by an external function. Can it be freed?

frederic-mahe commented 5 years ago

All swarm options are now covered by valgrind tests to detect errors and memory leaks (https://github.com/frederic-mahe/swarm-tests/commit/18691cc78f4ba9c6ea7e242ae35bcd6830554561).

torognes commented 5 years ago

Fixed in a43597b.

torognes commented 5 years ago

Now fixed in zobrist branch too: f16a45f

frederic-mahe commented 5 years ago

All valgind tests now pass without error. Good job.