From cac72a0cdfa28685645f43ae91fe8e5fef5d8708 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Mon, 6 Dec 2021 15:51:49 +0900 Subject: [PATCH] Fix memory leak with AVPacket, OpenCL logs --- src/opencl_handle.cc | 2 ++ src/video.cc | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/opencl_handle.cc b/src/opencl_handle.cc index addfba8..ce047fe 100644 --- a/src/opencl_handle.cc +++ b/src/opencl_handle.cc @@ -11,6 +11,7 @@ OpenCLContext::Ptr OpenCLContext::instance_ = {}; OpenCLContext::OpenCLHandle::OpenCLHandle() : opencl_ptr_(), kernels_() {} OpenCLContext::OpenCLHandle::~OpenCLHandle() { + std::cout << "Destructing OpenCLHandle..." << std::endl; CleanupAllKernels(); OpenCLContext::CleanupInstance(); } @@ -769,6 +770,7 @@ OpenCLContext::OpenCLContext() : context_(nullptr), queue_(nullptr) { } OpenCLContext::~OpenCLContext() { + std::cout << "Destructing OpenCLContext..." << std::endl; if (queue_) { clReleaseCommandQueue(queue_); } diff --git a/src/video.cc b/src/video.cc index bac0b91..d604da5 100644 --- a/src/video.cc +++ b/src/video.cc @@ -295,6 +295,7 @@ bool Video::DitherVideo(const std::string &output_filename, Image *blue_noise, avcodec_close(enc_codec_context); avformat_free_context(avf_enc_context); av_frame_free(&frame); + av_packet_unref(pkt); av_packet_free(&pkt); avcodec_free_context(&codec_ctx); avformat_close_input(&avf_dec_context); @@ -307,6 +308,7 @@ bool Video::DitherVideo(const std::string &output_filename, Image *blue_noise, avcodec_close(enc_codec_context); avformat_free_context(avf_enc_context); av_frame_free(&frame); + av_packet_unref(pkt); av_packet_free(&pkt); avcodec_free_context(&codec_ctx); avformat_close_input(&avf_dec_context); @@ -316,6 +318,7 @@ bool Video::DitherVideo(const std::string &output_filename, Image *blue_noise, } } } + av_packet_unref(pkt); } // flush decoders