[matroska-devel] Re: Memory leaks in libmatroska partially fixed

Steve Lhomme steve.lhomme at free.fr
Tue Feb 25 15:52:50 CET 2003

En réponse à Moritz Bunkus <moritz at bunkus.org>:

> Hi.
> Ok, now I'm a bit more precise than before. Most of the bytes leaked
> were definitely my fault, but there are some leaks that I'm pretty
> sure
> are NOT my fault.
> The first thing happens when the following function is used to render
> the head:
> static void render_head(StdIOCallback *out) {
>   EbmlHead head;
>   EDocType &doc_type = GetChild<EDocType>(head);
>   *static_cast<EbmlString *>(&doc_type) = "matroska";
>   EDocTypeVersion &doc_type_ver = GetChild<EDocTypeVersion>(head);
>   *(static_cast<EbmlUInteger *>(&doc_type_ver)) = 1;
>   EDocTypeReadVersion &doc_type_read_ver =
>     GetChild<EDocTypeReadVersion>(head);
>   *(static_cast<EbmlUInteger *>(&doc_type_read_ver)) = 1;
>   head.Render(static_cast<StdIOCallback &>(*out));
> }
> As far as I understand the head is being destroyed when the function
> is
> done and should free all memory allocated with it. But it does
> not. Valgrind's output for it can be found at
> http://www.linet-services.de/~mbunkus/val-head.txt
> Or am I doing something wrong here? 

No that's correct. The allocated memory is not freed because, as I said in the
previous email, the chidren on "head" are not freed when "head" is (which is an
EbmlMaster). I'll add something to automatically free these EbmlMaster children.

I will use a locking system so that if you really want to keep an element in
memory, you can (and you become the father will all responsabilites ;).

More information about the Matroska-devel mailing list