membraneframework/membrane_rtmp_plugin

Memory Leak

dmorn opened this issue · 2 comments

dmorn commented

We noticed that our pipeline was leaking memory equal to the audio/video data
passing through it. The BEAM was not reporting a leak, ps -o rss was. For this
reason, we suspected the leakage was to be found within the nifs.

This mail
exchange

made us double check the av_interleave_write function and we noticed that
packet->data field was set directly: libav tells instead to add a reference
counted buf to the packet so that the data payload can be freed by the library
as soon as nobody is referencing it.

We probed the memory, draw some graphs: the leakage is here!

dmorn commented

You can see the trend in the following visualization (memory usage goes up and down like this as the RTMP sink was attached to an HLS source)
visualization(2)

dmorn commented

Solved with #31 !