8000 Fix memory leaks in FFmpegController, iina#1720 by logchan · Pull Request #2 · logchan/iina · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Sep 13, 2022. It is now read-only.

Fix memory leaks in FFmpegController, iina#1720 #2

Merged
merged 1 commit into from
Oct 27, 2021

Conversation

logchan
Copy link
Owner
@logchan logchan commented Oct 27, 2021

The method getPeeksForFile in FFmpegController is leaking memory
when generating thumbnails. This commit will:

  • Add a @try-@finally block in the while loop to free the packet

  • Replace av_free by av_frame_free, when freeing an AVFrame

  • Add a call to sws_freeContext to free the SwsContext

  • Replace deprecated method avcodec_close with avcodec_free_context

  • Add nullable annotation to declaration of probeVideoInfoForFile

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.

  • This change has been discussed with the author.
  • It implements / fixes issue #.

Description:

The method `getPeeksForFile` in `FFmpegController` is leaking memory
when generating thumbnails. This commit will:

- Add a `@try-@finally` block in the while loop to free the packet

- Replace `av_free` by `av_frame_free`, when freeing an `AVFrame`

- Add a call to `sws_freeContext` to free the `SwsContext`

- Replace deprecated method `avcodec_close` with `avcodec_free_context`

- Add `nullable` annotation to declaration of `probeVideoInfoForFile`

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.
@logchan logchan merged commit e388d83 into logchan:develop Oct 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0