[prev in list] [next in list] [prev in thread] [next in thread] 

List:       taglib-devel
Subject:    Re: memory leak in id3v2framefactory.cpp
From:       Scott Wheeler <wheeler () kde ! org>
Date:       2011-02-02 15:47:07
Message-ID: 3B032CB0-F32B-4C4E-A5D7-3B22E6E46D60 () kde ! org
[Download RAW message or body]

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
_______________________________________________
taglib-devel mailing list
taglib-devel@kde.org
https://mail.kde.org/mailman/listinfo/taglib-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic