Ensembl / Bio-DB-HTS

Git repo for Bio::DB::HTS module on CPAN, providing Perl links into HTSlib
Apache License 2.0
24 stars 16 forks source link

Refcount-based fix for index memory releasing problem #68

Closed jmarshall closed 6 years ago

jmarshall commented 6 years ago

On #67, I wrote

It would probably be possible to add a reference to the Bio::DB::HTSfile to the Bio::DB::HTS::Index object to get the objects destroyed in the right order. Either in the XS code (non-trivial) or in the Perl wrappers (hopefully easier).

This implements that. First attempt was via sv_magic(), but that didn't get the ordering right. Using an external global hash is a bit more manual but also more explicit.

avullo commented 6 years ago

That's very nice @jmarshall, I couldn't think of a better way of solving this. I guess you've checked with environment which was causing you problems (5.10.1) and it didn't show problems running it multiple times.

jmarshall commented 6 years ago

Yes, with this change there's no valgrind invalid read errors on Perl 5.10.1 for t/03cram.t. Across many runs.

valgrind ./Build test completes without problems too.

avullo commented 6 years ago

Brilliant, getting this in

jmarshall commented 6 years ago

Thanks!

avullo commented 6 years ago

:+1: :+1: