Fix memory leaks in FFmpegController, #1720 #3461
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The method
getPeeksForFile
inFFmpegController
is leaking memorywhen generating thumbnails. This commit will:
Add a
@try-@finally
block in the while loop to free the packetReplace
av_free
byav_frame_free
, when freeing anAVFrame
Add a call to
sws_freeContext
to free theSwsContext
Replace deprecated method
avcodec_close
withavcodec_free_context
Add
nullable
annotation to declaration ofprobeVideoInfoForFile
This is a stopgap fix and does not address all of the potential leaks
in the method. This commit focuses on the leaks that occur during the
normal flow when generating thumbnails. Error flows will still leak
memory. At some point this method should be refactored to always
properly free memory.
Description: