[Live-devel] To avoid memory leak.
Ross Finlayson
finlayson at live.com
Wed Feb 9 13:29:40 PST 2005
At 11:21 AM 2/9/05, you wrote:
>After I terminated a thread running with
>"env->taskScheduler().doEventLoop();", what should I do to clear all
>resources hold by the following variables?
>
> UsageEnvironment *env;
>
> AudioInputDevice *source;
> SimpleRTPSink *sink;
> or
> SimpleRTPSource *source;
> FileSink *sink;
>
> RTCPInstance* rtcpInstance;
>
> Groupsock* rtpGroupsock;
> Groupsock* rtcpGroupsock;
>A user may start or stop the streamer or receiver with different multicast
>address, sampling frequence, so memory leak is concerned.
>Will "Media::Close" be enough for all its subclasses?
Yes, calling "Medium::close()" on each media object should be sufficient
(*except* for the "Groupsock" objects; they're just reclaimed using
"delete"). Also, the "UsageEnvironment" object is reclaimed using
"UsageEnvironment::reclaim()".
In general, you should reclaim objects in the opposite order in which they
were created. So, for example, call
Medium::close(rtcpInstance);
before calling
delete rtcpGroupsock;
"env->reclaim();" should be the last thing you call.
Ross Finlayson
LIVE.COM
<http://www.live.com/>
More information about the live-devel
mailing list