<br><br><div class="gmail_quote">On Sun, Jun 12, 2011 at 12:30 AM, <span dir="ltr"><<a href="mailto:flac-dev-request@xiph.org">flac-dev-request@xiph.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Send Flac-dev mailing list submissions to<br>
<a href="mailto:flac-dev@xiph.org">flac-dev@xiph.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://lists.xiph.org/mailman/listinfo/flac-dev" target="_blank">http://lists.xiph.org/mailman/listinfo/flac-dev</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:flac-dev-request@xiph.org">flac-dev-request@xiph.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:flac-dev-owner@xiph.org">flac-dev-owner@xiph.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Flac-dev digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Memory leak using libflac++ (Andy Hawkins)<br>
2. Re: Memory leak using libflac++ (Stephen F. Booth)<br>
3. Re: Memory leak using libflac++ (Andy Hawkins)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Fri, 10 Jun 2011 15:39:41 +0000 (UTC)<br>
From: Andy Hawkins <<a href="mailto:andy@gently.org.uk">andy@gently.org.uk</a>><br>
Subject: [Flac-dev] Memory leak using libflac++<br>
To: <a href="mailto:flac-dev@xiph.org">flac-dev@xiph.org</a><br>
Message-ID: <<a href="mailto:slrniv4elt.uti.andy@atom.gently.org.uk">slrniv4elt.uti.andy@atom.gently.org.uk</a>><br>
Content-Type: text/plain; charset=us-ascii<br>
<br>
Hi all,<br>
<br>
I'm the author of flactag, a utility for tagging whole-album FLAC files with<br>
embedded CUE sheets using data from the MusicBrainz servers.<br>
<br>
I've recently run it through valgrind, and I'm seeing memory leaks like the<br>
following:<br>
<br>
12 bytes in 1 blocks are definitely lost in loss record 1 of 5<br>
at 0x402377E: operator new(unsigned) (vg_replace_malloc.c:224)<br>
by 0x41448A8: FLAC::Metadata::local::construct_block(FLAC__StreamMetadata*)<br>
(in /usr/lib/libFLAC++.so.6.2.0) by 0x41455D7:<br>
FLAC::Metadata::Iterator::get_block() (in /usr/lib/libFLAC++.so.6.2.0)<br>
by 0x8072CB5: CFlacInfo::Read() (FlacInfo.cc:154)<br>
by 0x8054BF4: CFlacTag::LoadData() (flactag.cc:543)<br>
by 0x8058D45: CFlacTag::CFlacTag(CCommandLine const&) (flactag.cc:134)<br>
by 0x805D4E2: main (flactag.cc:66)<br>
<br>
In my code, the offending line is:<br>
<br>
m_PictureBlock=(FLAC::Metadata::Picture*)Iterator.get_block();<br>
<br>
(m_PictureBlock is a pointer to a FLAC::Metadata::Picture object).<br>
<br>
The documentation seems to imply that you don't need to delete the pointer<br>
that is returned here, but the memory leak report seems to contradict that.<br>
<br>
Can anyone tell me if I should be deleteing this point? Or is there<br>
something else I should be doing to clean up?<br>
<br>
Thanks<br>
<br>
Andy<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Fri, 10 Jun 2011 21:49:58 -0400<br>
From: "Stephen F. Booth" <<a href="mailto:me@sbooth.org">me@sbooth.org</a>><br>
Subject: Re: [Flac-dev] Memory leak using libflac++<br>
To: <a href="mailto:flac-dev@xiph.org">flac-dev@xiph.org</a><br>
Message-ID: <BANLkTi=<a href="mailto:L%2BXNe3zVRoVMzSYvCwVhtpNh7xQ@mail.gmail.com">L+XNe3zVRoVMzSYvCwVhtpNh7xQ@mail.gmail.com</a>><br>
Content-Type: text/plain; charset=ISO-8859-1<br>
<br>
> I've recently run it through valgrind, and I'm seeing memory leaks like the<br>
> following:<br>
><br>
> 12 bytes in 1 blocks are definitely lost in loss record 1 of 5<br>
> at 0x402377E: operator new(unsigned) (vg_replace_malloc.c:224)<br>
> by 0x41448A8: FLAC::Metadata::local::construct_block(FLAC__StreamMetadata*)<br>
> (in /usr/lib/libFLAC++.so.6.2.0) ? by 0x41455D7:<br>
> FLAC::Metadata::Iterator::get_block() (in /usr/lib/libFLAC++.so.6.2.0)<br>
> by 0x8072CB5: CFlacInfo::Read() (FlacInfo.cc:154)<br>
> by 0x8054BF4: CFlacTag::LoadData() (flactag.cc:543)<br>
> by 0x8058D45: CFlacTag::CFlacTag(CCommandLine const&) (flactag.cc:134)<br>
> by 0x805D4E2: main (flactag.cc:66)<br>
><br>
> In my code, the offending line is:<br>
><br>
> m_PictureBlock=(FLAC::Metadata::Picture*)Iterator.get_block();<br>
<br>
I've never used the C++ API, but the source for get_block() is just:<br>
<br>
return local::construct_block(::FLAC__metadata_simple_iterator_get_block(iterator_));<br>
<br>
and construct_block() looks like (simplified for the picture case):<br>
<br>
Prototype *ret = 0;<br>
ret = new Picture(object, /*copy=*/false);<br>
return ret;<br>
<br>
So I don't see any way this couldn't be a leak if you aren't deleting<br>
the pointer returned from get_block().<br>
<br>
The documentation says:<br>
<br>
* The ownership of pointers in the C++ layer follows that in<br>
* the C layer, i.e.<br>
* - The objects returned by get_block() are yours to<br>
* modify, but changes are not reflected in the FLAC file<br>
* until you call set_block(). The objects are also<br>
* yours to delete; they are not automatically deleted<br>
* when passed to set_block() or insert_block_after().<br>
<br>
So I think it will be necessary for you to delete the object manually.<br>
<br>
Stephen<br>
<br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Sat, 11 Jun 2011 11:22:28 +0000 (UTC)<br>
From: Andy Hawkins <<a href="mailto:andy@gently.org.uk">andy@gently.org.uk</a>><br>
Subject: Re: [Flac-dev] Memory leak using libflac++<br>
To: <a href="mailto:flac-dev@xiph.org">flac-dev@xiph.org</a><br>
Message-ID: <<a href="mailto:slrniv6jvk.joo.andy@atom.gently.org.uk">slrniv6jvk.joo.andy@atom.gently.org.uk</a>><br>
Content-Type: text/plain; charset=us-ascii<br>
<br>
Hi,<br>
<br>
In article <BANLkTi=<a href="mailto:L%2BXNe3zVRoVMzSYvCwVhtpNh7xQ@mail.gmail.com">L+XNe3zVRoVMzSYvCwVhtpNh7xQ@mail.gmail.com</a>>,<br>
Stephen F. Booth<<a href="mailto:me@sbooth.org">me@sbooth.org</a>> wrote:<br>
> I've never used the C++ API, but the source for get_block() is just:<br>
><br>
> return local::construct_block(::FLAC__metadata_simple_iterator_get_block(iterator_));<br>
><br>
> and construct_block() looks like (simplified for the picture case):<br>
><br>
> Prototype *ret = 0;<br>
> ret = new Picture(object, /*copy=*/false);<br>
> return ret;<br>
><br>
> So I don't see any way this couldn't be a leak if you aren't deleting<br>
> the pointer returned from get_block().<br>
><br>
> The documentation says:<br>
><br>
> * The ownership of pointers in the C++ layer follows that in<br>
> * the C layer, i.e.<br>
> * - The objects returned by get_block() are yours to<br>
> * modify, but changes are not reflected in the FLAC file<br>
> * until you call set_block(). The objects are also<br>
> * yours to delete; they are not automatically deleted<br>
> * when passed to set_block() or insert_block_after().<br>
><br>
> So I think it will be necessary for you to delete the object manually.<br>
<br>
Thanks for that. Can't find all of that in the documentation I'm looking at:<br>
<br>
<a href="http://flac.sourceforge.net/api/index.html" target="_blank">http://flac.sourceforge.net/api/index.html</a><br>
<br>
However, it does all make sense and ties in with my reading of the library<br>
source too.<br>
<br>
Thanks a lot for the response.<br>
<br>
Andy<br>
<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
Flac-dev mailing list<br>
<a href="mailto:Flac-dev@xiph.org">Flac-dev@xiph.org</a><br>
<a href="http://lists.xiph.org/mailman/listinfo/flac-dev" target="_blank">http://lists.xiph.org/mailman/listinfo/flac-dev</a><br>
<br>
<br>
End of Flac-dev Digest, Vol 79, Issue 3<br>
***************************************<br>
</blockquote></div><br><br clear="all"><br>-- <br>Thanks & Regards<br>Tarun Chauhan<br> +91 - 9266858589<br> +91 - 8447763691<br><div> </div><br>