[Live-devel] small leaks?

Gabriel Bouvigne gabriel.bouvigne at resonate-mp4.com
Mon Jun 21 16:07:16 PDT 2004


Ross Finlayson a écrit :

> 
>> *media.cpp, _Tables* getOurTables(UsageEnvironment& env)
>> l 49:
>>     env.liveMediaPriv = new _Tables;
>>
>> But nowhere I see deletion of liveMediaPriv.
> 
> 
> Yes, this is a 'leak', albeit an unimportant one, because programs that 
> use these libraries will typically create very few "UsageEnvironment" 
> objects (in fact, usually just one), and the lifetime of these objects 
> will typically be the same as that of the entire program.
> 
> Unfortunately, there's no good way to fix this without making the 
> "UsageEnvironment" class aware of the "liveMedia" library - something 
> that I don't want to do, because I want to allow for programs that use 
> the "UsageEnvironment" library without the "liveMedia" library.  But as 
> I noted above, this is not an important 'leak'.


I understand.
An alternative way to cure this would be to delete liveMediaPriv in 
BasicUsageEnvironment instead of in UsageEnvironment:

BasicUsageEnvironment::~BasicUsageEnvironment() {
     if (liveMediaPriv != NULL){
         delete (_Tables*)liveMediaPriv;
         liveMediaPriv = NULL;
     }
}

This solves my problem, but of someone is subclassing UsageEnvironment 
in his own class, the leak will reappear.

Regards,

-- 

Gabriel Bouvigne
Resonate mp4
Tel: (+33) 142 411 665


More information about the live-devel mailing list