• wm4's avatar
    lavu: fix memory leaks by using a mutex instead of atomics · fbd6c97f
    wm4 authored
    The buffer pool has to atomically add and remove entries from the linked
    list of available buffers. This was done by removing the entire list
    with a CAS operation, working on it, and then setting it back again
    (using a retry-loop in case another thread was doing the same thing).
    
    This could effectively cause memory leaks: while a thread was working on
    the buffer list, other threads would allocate new buffers, increasing
    the pool's total size. There was no real leak, but since these extra
    buffers were not needed, but not free'd either (except when the buffer
    pool was destroyed), this had the same effects as a real leak. For some
    reason, growth was exponential, and could easily kill the process due
    to OOM in real-world uses.
    
    Fix this by using a mutex to protect the list operations. The fancy
    way atomics remove the whole list to work on it is not needed anymore,
    which also avoids the situation which was causing the leak.
    Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
    fbd6c97f
Name
Last commit
Last update
compat Loading commit data...
doc Loading commit data...
libavcodec Loading commit data...
libavdevice Loading commit data...
libavfilter Loading commit data...
libavformat Loading commit data...
libavresample Loading commit data...
libavutil Loading commit data...
libswscale Loading commit data...
presets Loading commit data...
tests Loading commit data...
tools Loading commit data...
.gitignore Loading commit data...
COPYING.GPLv2 Loading commit data...
COPYING.GPLv3 Loading commit data...
COPYING.LGPLv2.1 Loading commit data...
COPYING.LGPLv3 Loading commit data...
CREDITS Loading commit data...
Changelog Loading commit data...
INSTALL Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
README Loading commit data...
README.md Loading commit data...
RELEASE Loading commit data...
arch.mak Loading commit data...
avconv.c Loading commit data...
avconv.h Loading commit data...
avconv_dxva2.c Loading commit data...
avconv_filter.c Loading commit data...
avconv_opt.c Loading commit data...
avconv_vda.c Loading commit data...
avconv_vdpau.c Loading commit data...
avplay.c Loading commit data...
avprobe.c Loading commit data...
cmdutils.c Loading commit data...
cmdutils.h Loading commit data...
cmdutils_common_opts.h Loading commit data...
common.mak Loading commit data...
configure Loading commit data...
library.mak Loading commit data...
version.sh Loading commit data...