memory leak in id3v2framefactory.cpp

Scott Wheeler wheeler at kde.org
Wed Feb 2 16:47:07 CET 2011


On Feb 1, 2011, at 12:29 AM, Daniel Schaack wrote:

> Seems like the static variable:
>
> FrameFactory *FrameFactory::factory = 0;
>
> in id3v2framefactory.cpp
>
> doesnt' get deleted when my app closes. I'm using the static version  
> of
> TagLib.

No, it doesn't, but it doesn't matter.  Honestly, when that code was  
written was largely before people starting using tools that reported  
these things and the only reason to care about that "leak" is to make  
it appear sanitary with said tools.  A "leak" implies continual  
lossage, this is more like a "pool" that doesn't get emptied.  ;-)

Basically it's only allocated once, there's no destructor that needs  
to be called, and the net effect is that the memory is freed when the  
application exits, which is exactly what would happen if delete was  
called on it.

That said, these days I usually write something like:

FrameFactory *FrameFactory::instance()
{
   static FrameFactory f;
   return &f;
}

-Scott


More information about the taglib-devel mailing list