Memory leaks
Bastiaan Timmer
basjetimmer at yahoo.com
Wed Apr 7 12:27:04 CEST 2010
Hi, I have been playing with the tagreader.cpp file from the examples directory, as I'm considering using this library in my application. When compiling the program and running it through valgrind, it shows some memory leaks. They are only small and don't seem to grow when running the example on multiple files. But the memory is reported 'still reachable' so it should be easy to fix, I think.
Valgrind output when running on a flac file:
[~] $ g++ -O0 -g tagreader.cpp -o readtag -ltag
[~] $ valgrind --leak-check=full --show-reachable=yes ./readtag testfiles/test.flac
==18913== Memcheck, a memory error detector.
==18913== Copyright (C) 2002-2008, and GNU GPL'd, by Julian Seward et al.
==18913== Using LibVEX rev 1884, a library for dynamic binary translation.
==18913== Copyright (C)
2004-2008, and GNU GPL'd, by OpenWorks LLP.
==18913== Using valgrind-3.4.1, a dynamic binary instrumentation framework.
==18913== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al.
==18913== For more details, rerun with: -v
==18913==
******************** "programming/audio-2/testpack/FILES/test.flac" ********************
-- TAG --
title - "title_test"
artist - "artist_test"
album - "album_test"
year - "2012"
comment - "Encoded by FLAC v1.1.2a with FLAC Frontend v1.7.1"
track - "11"
genre - ""
-- AUDIO --
bitrate - 1032
sample rate - 44100
channels - 2
length - 5:53
==18913==
==18913== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 18 from 1)
==18913== malloc/free: in use at exit: 20 bytes in 3 blocks.
==18913== malloc/free:
700 allocs, 697 frees, 23,219 bytes allocated.
==18913== For counts of detected errors, rerun with: -v
==18913== searching for pointers to 3 not-freed blocks.
==18913== checked 111,388 bytes.
==18913==
==18913== 4 bytes in 1 blocks are still reachable in loss record 1 of 3
==18913== at 0x40068AD: operator new(unsigned int) (vg_replace_malloc.c:224)
==18913== by 0x6019B2C: (within /usr/lib/libtag.so.1.6.1)
==18913== by 0x6067FBC: (within /usr/lib/libtag.so.1.6.1)
==18913== by 0x6013283: (within /usr/lib/libtag.so.1.6.1)
==18913== by 0x15E37B: call_init (in /lib/ld-2.10.2.so)
==18913== by 0x15E4E0: _dl_init (in /lib/ld-2.10.2.so)
==18913== by 0x14F88E: (within /lib/ld-2.10.2.so)
==18913==
==18913==
==18913== 8 bytes in 1 blocks are still reachable in loss record 2 of
3
==18913== at 0x40068AD: operator new(unsigned int) (vg_replace_malloc.c:224)
==18913== by 0x601D250: TagLib::ID3v2::FrameFactory::FrameFactory() (in /usr/lib/libtag.so.1.6.1)
==18913== by 0x601D3E0: TagLib::ID3v2::FrameFactory::instance() (in /usr/lib/libtag.so.1.6.1)
==18913== by 0x604A52A: TagLib::FLAC::File::File(char const*, bool, TagLib::AudioProperties::ReadStyle) (in /usr/lib/libtag.so.1.6.1)
==18913== by 0x606710B: TagLib::FileRef::create(char const*, bool, TagLib::AudioProperties::ReadStyle) (in /usr/lib/libtag.so.1.6.1)
==18913== by 0x6067B81: TagLib::FileRef::FileRef(char const*, bool, TagLib::AudioProperties::ReadStyle) (in /usr/lib/libtag.so.1.6.1)
==18913== by 0x8048B42: main (tagreader.cpp:46)
==18913==
==18913==
==18913== 8 bytes in 1 blocks are still reachable in loss record 3 of
3
==18913== at 0x40068AD: operator new(unsigned int) (vg_replace_malloc.c:224)
==18913== by 0x601D3D3: TagLib::ID3v2::FrameFactory::instance() (in /usr/lib/libtag.so.1.6.1)
==18913== by 0x604A52A: TagLib::FLAC::File::File(char const*, bool, TagLib::AudioProperties::ReadStyle) (in /usr/lib/libtag.so.1.6.1)
==18913== by 0x606710B: TagLib::FileRef::create(char const*, bool, TagLib::AudioProperties::ReadStyle) (in /usr/lib/libtag.so.1.6.1)
==18913== by 0x6067B81: TagLib::FileRef::FileRef(char const*, bool, TagLib::AudioProperties::ReadStyle) (in /usr/lib/libtag.so.1.6.1)
==18913== by 0x8048B42: main (tagreader.cpp:46)
==18913==
==18913== LEAK SUMMARY:
==18913== definitely lost: 0 bytes in 0 blocks.
==18913== possibly lost: 0 bytes in 0 blocks.
==18913==
still reachable: 20 bytes in 3 blocks.
==18913== suppressed: 0 bytes in 0 blocks.
[~] $
Using an mp3 file, the leaks are nearly identical, but not quite:
==18917==
==18917== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 17 from 1)
==18917== malloc/free: in use at exit: 20 bytes in 3 blocks.
==18917== malloc/free: 1,972 allocs, 1,969 frees, 111,439 bytes allocated.
==18917== For counts of detected errors, rerun with: -v
==18917== searching for pointers to 3 not-freed blocks.
==18917== checked 111,388 bytes.
==18917==
==18917== 4 bytes in 1 blocks are still reachable in loss record 1 of 3
==18917== at 0x40068AD: operator new(unsigned int) (vg_replace_malloc.c:224)
==18917== by 0x6019B2C: (within /usr/lib/libtag.so.1.6.1)
==18917== by 0x6067FBC: (within
/usr/lib/libtag.so.1.6.1)
==18917== by 0x6013283: (within /usr/lib/libtag.so.1.6.1)
==18917== by 0x15E37B: call_init (in /lib/ld-2.10.2.so)
==18917== by 0x15E4E0: _dl_init (in /lib/ld-2.10.2.so)
==18917== by 0x14F88E: (within /lib/ld-2.10.2.so)
==18917==
==18917==
==18917== 8 bytes in 1 blocks are still reachable in loss record 2 of 3
==18917== at 0x40068AD: operator new(unsigned int) (vg_replace_malloc.c:224)
==18917== by 0x601D250: TagLib::ID3v2::FrameFactory::FrameFactory() (in /usr/lib/libtag.so.1.6.1)
==18917== by 0x601D3E0: TagLib::ID3v2::FrameFactory::instance() (in /usr/lib/libtag.so.1.6.1)
==18917== by 0x6017A1C: TagLib::MPEG::File::File(char const*, bool, TagLib::AudioProperties::ReadStyle) (in /usr/lib/libtag.so.1.6.1)
==18917== by 0x6066F78:
TagLib::FileRef::create(char const*, bool, TagLib::AudioProperties::ReadStyle) (in /usr/lib/libtag.so.1.6.1)
==18917== by 0x6067B81: TagLib::FileRef::FileRef(char const*, bool, TagLib::AudioProperties::ReadStyle) (in /usr/lib/libtag.so.1.6.1)
==18917== by 0x8048B42: main (tagreader.cpp:46)
==18917==
==18917==
==18917== 8 bytes in 1 blocks are still reachable in loss record 3 of 3
==18917== at 0x40068AD: operator new(unsigned int) (vg_replace_malloc.c:224)
==18917== by 0x601D3D3: TagLib::ID3v2::FrameFactory::instance() (in /usr/lib/libtag.so.1.6.1)
==18917== by 0x6017A1C: TagLib::MPEG::File::File(char const*, bool, TagLib::AudioProperties::ReadStyle) (in /usr/lib/libtag.so.1.6.1)
==18917== by 0x6066F78: TagLib::FileRef::create(char const*, bool, TagLib::AudioProperties::ReadStyle) (in
/usr/lib/libtag.so.1.6.1)
==18917== by 0x6067B81: TagLib::FileRef::FileRef(char const*, bool, TagLib::AudioProperties::ReadStyle) (in /usr/lib/libtag.so.1.6.1)
==18917== by 0x8048B42: main (tagreader.cpp:46)
==18917==
==18917== LEAK SUMMARY:
==18917== definitely lost: 0 bytes in 0 blocks.
==18917== possibly lost: 0 bytes in 0 blocks.
==18917== still reachable: 20 bytes in 3 blocks.
==18917== suppressed: 0 bytes in 0 blocks.
When running on an OGG/Vorbis file, only the first block is reported:
==18921==
==18921== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 17 from 1)
==18921== malloc/free: in use at exit: 4 bytes in 1 blocks.
==18921== malloc/free: 759 allocs, 758 frees, 32,212 bytes allocated.
==18921== For counts of detected errors, rerun with:
-v
==18921== searching for pointers to 1 not-freed blocks.
==18921== checked 111,376 bytes.
==18921==
==18921== 4 bytes in 1 blocks are still reachable in loss record 1 of 1
==18921== at 0x40068AD: operator new(unsigned int) (vg_replace_malloc.c:224)
==18921== by 0x6019B2C: (within /usr/lib/libtag.so.1.6.1)
==18921== by 0x6067FBC: (within /usr/lib/libtag.so.1.6.1)
==18921== by 0x6013283: (within /usr/lib/libtag.so.1.6.1)
==18921== by 0x15E37B: call_init (in /lib/ld-2.10.2.so)
==18921== by 0x15E4E0: _dl_init (in /lib/ld-2.10.2.so)
==18921== by 0x14F88E: (within /lib/ld-2.10.2.so)
==18921==
==18921== LEAK SUMMARY:
==18921== definitely lost: 0 bytes in 0 blocks.
==18921== possibly lost: 0 bytes in 0 blocks.
==18921==
still reachable: 4 bytes in 1 blocks.
==18921== suppressed: 0 bytes in 0 blocks.
Is there something wrong with the example, with the library, or with my understanding of any of this?
Thanks!
bepaald
More information about the taglib-devel
mailing list