[Live-devel] File handle leak in slightly modified testMPEG2TransportStreamer

Warren Young warren at etr-usa.com
Thu Jan 30 16:06:49 PST 2014


In an attempt to reduce the number of global variables in 
testMPEG2TransportStreamer.cpp, I made videoSource a local variable in 
play(), then said

     Medium::close(videoSink->source());

in afterPlaying().

This appears to work, but if you watch the FD count, it goes up by one 
per pass through play().

On investigating, I discovered that videoSink->source() does not return 
the same pointer as was passed to videoSink->startPlaying()!  This 
apparently results in the ByteStreamFileSource instance not being 
cleaned up, which explains the handle leak.

This leak is mostly harmless...until you try to play a 6-second video in 
a continuous loop for 14 hours. :)  The default FD limit of 1024 on 
Linux gets exhausted in about 2 hours.

Is this all as expected, by design, or is Medium::close() not as smart 
as it should be about chasing down unused resources?


More information about the live-devel mailing list