<div dir="ltr">Hi<div><br></div><div>I'm facing a high memory usage consumption on video decoding, seems to be some memory leak, but I did not manage to find it.</div><div><br></div><div>Processor:11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz   2.69 GHz, 6 cores, 12 threads</div><div>GPU: NVIDIA GeForce RTX 3050 Laptop GPU, 4gb GDDR6 6001.0 MHz</div><div>OS: </div><div><br></div><div>I've tried with CUDA, D3D11VA and DXVA2, until now DXVA2 presents the best results.</div><div><br></div><div>These are the steps:</div><div><br></div><div><ol><li>Initialize TAVHWDeviceType by av_hwdevice_find_type_by_name('dxva2')</li><li>Initialize PAVCodec by avcodec_find_decoder(), it's TAVCodecId parameter can assume one of these values 

[Mpeg4, H264, HEVC, MJPEG]</li><li>Initialize PAVCodecHWConfig by:<br>while True do<br>begin<br>  vHWConfig := avcodec_get_hw_config(fCodec, vCount);<br><br>  Inc(vCount);<br><br>  if not Assigned(vHWConfig) then<br>    Break;<br><br>  if ((vHWConfig.methods and AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) <> 0) and (vHWConfig.device_type = vType) then<br>    fHWPixelFormat := vHWConfig.pix_fmt;<br>end;<br></li><li>Use av_hwdevice_ctx_create to set in PAVCodecContext.hw_device_ctx variable</li><li>When decoding I'm using avcodec_send_packet and avcodec_receive_frame functions</li><li>Using av_hwframe_transfer_data to copy from GPU memory to CPU memory</li><li>Finally I'm using sws_getContext and sw_scale to convert the image</li><li>After decoding these variables are been cleaned:<br>av_frame_free(@vSWFrame);<br>av_buffer_unref(@vBuffer);<br>av_freep(@vBuffer);<br>av_packet_unref(@vPacket);<br>av_packet_free(@vPacket);<br></li></ol><div><br></div><div>I'm using Delphi 10.3 and FastMM4  doesn't report any memory leak, but all the RAM available it's being used.</div></div><div><br></div><div>Is there any known issue that can be causing this?</div></div>