<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@DengXian";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Plain Text Char";
margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.PlainTextChar
{mso-style-name:"Plain Text Char";
mso-style-priority:99;
mso-style-link:"Plain Text";
font-family:"Calibri",sans-serif;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoPlainText">Unfortunately, in my experimental environment, it looks unlikely that the objects are deleted, even after 60 seconds.<o:p></o:p></p>
<p class="MsoPlainText">The clients will disconnect after sending each request.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Continuing sending the same request, after 10 minutes, the memory consumption reaches 16GB<o:p></o:p></p>
<p class="MsoPlainText"><img width="1064" height="55" style="width:11.0833in;height:.5729in" id="Picture_x0020_1" src="cid:image001.png@01D8063D.43860D20"><o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">I stop the client for three minutes after that, the memory consumption still does not decrease:<o:p></o:p></p>
<p class="MsoPlainText"><img width="1070" height="57" style="width:11.1458in;height:.5937in" id="Picture_x0020_2" src="cid:image002.png@01D8063D.B88957D0"><o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Best regards,<o:p></o:p></p>
<p class="MsoPlainText">Jinsheng Ba<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">-----Original Message-----<br>
From: live-devel <live-devel-bounces@us.live555.com> On Behalf Of Ross Finlayson<br>
Sent: Monday, January 10, 2022 3:48 PM<br>
To: LIVE555 Streaming Media - development & use <live-devel@us.live555.com><br>
Subject: Re: [Live-devel] Memory leak in OnDemandServerMediaSubsession</p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"> - External Email -<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> On Jan 10, 2022, at 7:54 PM, Ba Jinsheng <<a href="mailto:bajinsheng@u.nus.edu"><span style="color:windowtext;text-decoration:none">bajinsheng@u.nus.edu</span></a>> wrote:<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> I am not sure if the design is like this, but it does incur unstopping memory increasing.<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> OnDemandServerMediaSubsession::getStreamParameters() in liveMedia/OnDemandServerMediaSubsession.cpp<o:p></o:p></p>
<p class="MsoPlainText">> This function will allocate a new StreamState object and append it to the global array: fStreamStates.<o:p></o:p></p>
<p class="MsoPlainText">> Within the new StreamState, some objects are allocated, such as rtcpGroupsock.<o:p></o:p></p>
<p class="MsoPlainText">> However these new allocated memory seem only be freed by streamState->reclaim(); in afterPlayingStreamState() function.<o:p></o:p></p>
<p class="MsoPlainText">> And this function seems not be executed.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">“StreamState::reclaim()” is also called by the “StreamState” destructor, which is called by "OnDemandServerMediaSubsession::deleteStream()”.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">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:<o:p></o:p></p>
<p class="MsoPlainText"> - the client sends a RTSP “TEARDOWN” request for this session, or<o:p></o:p></p>
<p class="MsoPlainText"> - 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).<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">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).<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Ross Finlayson<o:p></o:p></p>
<p class="MsoPlainText">Live Networks, Inc.<o:p></o:p></p>
<p class="MsoPlainText"><a href="http://www.live555.com/"><span style="color:windowtext;text-decoration:none">http://www.live555.com/</span></a><o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">_______________________________________________<o:p></o:p></p>
<p class="MsoPlainText">live-devel mailing list<o:p></o:p></p>
<p class="MsoPlainText"><a href="mailto:live-devel@lists.live555.com"><span style="color:windowtext;text-decoration:none">live-devel@lists.live555.com</span></a><o:p></o:p></p>
<p class="MsoPlainText"><a href="http://lists.live555.com/mailman/listinfo/live-devel"><span style="color:windowtext;text-decoration:none">http://lists.live555.com/mailman/listinfo/live-devel</span></a><o:p></o:p></p>
</div>
</body>
</html>