From: Stephen Seo Date: Mon, 6 Dec 2021 06:51:49 +0000 (+0900) Subject: Fix memory leak with AVPacket, OpenCL logs X-Git-Url: https://git.seodisparate.com/stephenseo/static/gitweb.css?a=commitdiff_plain;h=cac72a0cdfa28685645f43ae91fe8e5fef5d8708;p=EN605.617.81.FA21_StephenSeo_DitheringProject Fix memory leak with AVPacket, OpenCL logs --- 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