提交 4459ed3e 编写于 作者: J jp9000

libobs: Fix memory leak (Enforce cache limit)

Under certain circumstances the cache could be prone to growing too
large unintentionally.  Setting a hard maximum limit should prevent
memory from growing if we suddenly get a lot of frames.
上级 6e22ac41
......@@ -1629,6 +1629,8 @@ static inline void free_async_cache(struct obs_source *source)
da_resize(source->async_frames, 0);
}
#define CACHE_LIMIT 30
static inline struct obs_source_frame *cache_video(struct obs_source *source,
const struct obs_source_frame *frame)
{
......@@ -1657,6 +1659,12 @@ static inline struct obs_source_frame *cache_video(struct obs_source *source,
}
if (!new_frame) {
/* ignore frames if cache limit reached */
if (source->async_cache.num == CACHE_LIMIT) {
pthread_mutex_unlock(&source->async_mutex);
return NULL;
}
struct async_frame new_af;
new_frame = obs_source_frame_create(frame->format,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册