[Live-devel] small leaks?

Florian Winter fw at graphics.cs.uni-sb.de
Mon Jun 21 16:34:29 PDT 2004


Ross Finlayson wrote:

>> *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. 

well, this is not true in general. in NMM we want to allow an unlimited 
number of RTP sessions in a single application, and there are
no restrictions on the lifetime. we create one UsageEnvironment object 
per session, which is necessary because each session runs in a separate
thread.

> 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'. 

there is no need to make the UsageEnvironment class aware of the 
liveMedia library. If the class of the object you want to delete
is not known, you can derive the class from an abstract base class and 
give it a virtual destructor. In UsageEnvironment you would have
a pointer to that abstract base and call delete on it. This invokes the 
virtual destructor. This also works if the UsageEnvironment is not even
linked to the liveMedia library.




More information about the live-devel mailing list