Open ghost opened 2 years ago
It seems that the memory leak comes from this commit.
The av_new_packet
function allocates a buffer for the packet:
int av_new_packet(AVPacket *pkt, int size)
{
AVBufferRef *buf = NULL;
int ret = packet_alloc(&buf, size);
if (ret < 0)
return ret;
av_init_packet(pkt);
pkt->buf = buf;
pkt->data = buf->data;
pkt->size = size;
return 0;
}
The buffer is later used in av_read_frame
, avcodec_send_packet
, etc., where extra references may be added to the buffer, resulting in the memory leak.
I'm not sure if this problem can be trivially fixed without changing gmf's API, or if it's a bug of FFmpeg. Using the deprecated av_init_packet
instead of av_new_packet
works fine, for now.
When running test
video-to-image.go
with valgrind, got the following results:The library is built with the latest release (4.4.2) of FFmpeg: