[Live-devel] Memory leak in OnDemandServerMediaSubsession

Ba Jinsheng bajinsheng at u.nus.edu
Mon Jan 10 00:18:37 PST 2022


Unfortunately, in my experimental environment, it looks unlikely that the objects are deleted, even after 60 seconds.

The clients will disconnect after sending each request.



Continuing sending the same request, after 10 minutes, the memory consumption reaches 16GB

[cid:image001.png at 01D8063D.43860D20]



I stop the client for three minutes after that, the memory consumption still does not decrease:

[cid:image002.png at 01D8063D.B88957D0]





Best regards,

Jinsheng Ba



-----Original Message-----
From: live-devel <live-devel-bounces at us.live555.com> On Behalf Of Ross Finlayson
Sent: Monday, January 10, 2022 3:48 PM
To: LIVE555 Streaming Media - development & use <live-devel at us.live555.com>
Subject: Re: [Live-devel] Memory leak in OnDemandServerMediaSubsession



        - External Email -







> On Jan 10, 2022, at 7:54 PM, Ba Jinsheng <bajinsheng at u.nus.edu<mailto:bajinsheng at u.nus.edu>> wrote:

>

> I am not sure if the design is like this, but it does incur unstopping memory increasing.

>

>

> OnDemandServerMediaSubsession::getStreamParameters() in liveMedia/OnDemandServerMediaSubsession.cpp

> This function will allocate a new StreamState object and append it to the global array: fStreamStates.

> Within the new StreamState, some objects are allocated, such as rtcpGroupsock.

> However these new allocated memory seem only be freed by streamState->reclaim(); in afterPlayingStreamState() function.

> And this function seems not be executed.



“StreamState::reclaim()” is also called by the “StreamState” destructor, which is called by "OnDemandServerMediaSubsession::deleteStream()”.



If a client repeatedly sends RTSP “SETUP” commands - with different session ids - to the server, then the server will, of course, allocate state for each session, in anticipation of the client later sending “PLAY” commands for each session.  The server will reclaim the state for each session if either:

        - the client sends a RTSP “TEARDOWN” request for this session, or

        - there is no client activity (RTSP or RTCP)  for the session after a timeout interval (by default, 60 seconds).  If this happens, then the "RTSPServer::RTSPClientSession” object (for the session) will be deleted, which will call "RTSPServer::RTSPClientSession::reclaimStreamStates()”, which will call "OnDemandServerMediaSubsession::deleteStream()”, which will delete the “StreamState” object (as noted above).



So I’m not seeing any memory leak here.  If you wait 60 seconds after each RTSP session is “SETUP”, then the “StreamState” objects should get deleted (unless your client is doing other RTSP things with each session).





Ross Finlayson

Live Networks, Inc.

http://www.live555.com/





_______________________________________________

live-devel mailing list

live-devel at lists.live555.com<mailto:live-devel at lists.live555.com>

http://lists.live555.com/mailman/listinfo/live-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20220110/5939716a/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 7338 bytes
Desc: image001.png
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20220110/5939716a/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 7692 bytes
Desc: image002.png
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20220110/5939716a/attachment-0003.png>


More information about the live-devel mailing list