[Live-devel] Memory leaks ?

Ross Finlayson finlayson at live.com
Thu Sep 8 14:30:09 PDT 2005


>I tested openRTSP.exe and located a few memory-leaks.
>
>1. I run openRTSP.exe -e 5 rtsp://192.168.7.199/mpeg4/1/media.amp
>
>subsession.sessionId is not deleted, it is called only in 
>teardownMediaSubsession, which is not called anywhere. Unfortunately 
>it is not called in teardownMediaSession().

That's a bug - thanks for noticing this.  I'll fix it in a future release.

>  I changed subsession destructor by adding delete[] sessionId.

No, because the "sessionId" field is assigned externally, outside the 
"MediaSubsession" class itself, its cleanup also needs to be done 
externally (in this case, in the "RTSPClient" code).  (For example, 
there's no reason why some other class that uses "MediaSubsession" 
couldn't assign the "sessionId" to be a static string, in which case 
we definitely wouldn't want "~MediaSubsession" to delete[] it.)


>2. I run TCP tunneled RTP by: openRTSP.exe -t -e 5 
>rtsp://192.168.7.199/mpeg4/1/media.amp
>
>'socketTable' is not removed. It is deleted in ~RCTPInstance(), but 
>next it is immediately created again in ~MuliFramedRTPSource, and 
>not deleted again because it is empty.
>You create 'socketTable' on request in socketHashTable(), but delete 
>it only in removeSocketDescriptor() which is error-prone as 
>'socketTable' is created initially empty, so 
>removeSocketDescriptor() will not be called in every situation.

I don't follow this.  "removeSocketDescription()" is called by 
"SocketDescriptor::deregisterRTPInterface()", which in turn is called 
by "RTPInterface::stopNetworkReading()", which in turn is called by 
both "~RTCPInstance()" and "~MultiFramedRTPSource()".  So, as long as 
the "RTCPInstance" and "MultiFramedRTPSource" objects are reclaimed 
(using "Medium::close()", the socket table should (eventually) get removed.

(In any case, it's only a small piece of memory that's allocated only 
once, so no big deal...)


>2. I run HTTP tunneled RTP by: openRTSP.exe -t -e 5 
>rtsp://192.168.7.199/mpeg4/1/media.amp
>
>In function RTSPClient::setupHTTPTunneling() variable cmd is not 
>deleted after first request. I added a single line:
>
>if ( !sendRequest( cmd, "HTTP GET", False)) break;
>delete[] cmd; cmd = NULL;

Yes, that was a bug.  I'll also fix this in a future release.


	Ross Finlayson
	Live Networks, Inc. (LIVE.COM)
	<http://www.live.com/>



More information about the live-devel mailing list