-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Memory leaks. #1720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I found three potentially problematic codes in the
There may be other leaks I did not find. |
Thanks for this!
Surely you mean
I see a call to |
Sorry, I made a typo and
I mean is that it should also call
|
OK, I found the last leaked code. |
@saagarjha |
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.
I found this issue searching to see if the memory leaks I'm experiencing have been reported. From reading related issues and pull requests I gather it was decided the correct fix required a major refactoring. Rewrites in Swift and C++ were worked on but were not merged. Then the issue ended up being left open. I didn't see any mention of using Objective-C's I'm proposing a 2 phase approach. First code a fix that minimizes the changes. Just simple changes that are easy to review. Fix the huge leaks for the normal flow. Get that merged. Then eventually refactor and cleanup the code so that it does not leak for the error cases. I've posted a pull request addressing the issues ldwardx detailed. This is intended to be a stopgap fix suitable for a minor bug fix release. This commit will:
Running a test where I first clear the cache by hand to force thumbnail generation and then open a video file the Output from leaks before changes:Process: IINA [68560] Path: /Users/USER/Library/Developer/Xcode/DerivedData/iina-echacgeisxgbwucwumppkhklmnkd/Build/Products/Debug/IINA.app/Contents/MacOS/IINA Load Address: 0x103dcc000 Identifier: com.colliderli.iina Version: 1.2.0 (129) Code Type: X86-64 Platform: macOS Parent Process: debugserver [68561]Date/Time: 2021-07-25 22:58:28.365 -0400 Physical footprint: 84.7M
|
Fix memory leaks in FFmpegController, iina#1720
commit d0c32125df2269621f0b6a85dabe36120a6d3f3b Merge: fea9399 a6b600d Author: Collider LI <lhc199652@gmail.com> Date: Thu Apr 28 02:12:43 2022 -0400 Merge branch 'issue-1720' of https://github.com/low-batt/iina into low-batt-issue-1720 commit a6b600d Author: low-batt <86170219+low-batt@users.noreply.github.com> Date: Sun Jul 25 23:14:05 2021 -0400 Fix memory leaks in FFmpegController, #1720 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.
The fix has been merged into the develop branch in commit 8682a54 |
Closing. Fixed in IINA 1.3.0. |
System and IINA version:
Expected behavior:
No leaks.
Actual behavior:
Steps to reproduce:
Play a video without cached thumbnails.
How often does this happen?
Every time a thumbnail is generated.
The text was updated successfully, but these errors were encountered: