-
Notifications
You must be signed in to change notification settings - Fork 212
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
repeatWithBehavior has memory leak #250
Comments
Hey, this isn't a valid Issue. Please provide many more details, analytics, reproduction, etc. |
The demo as above, can you help me, thanks |
Does anyone have the same problem? |
I copied your example into a project (it was pretty cumbersome considering you uploaded a screenshot, not the code itself), and I can confirm that memory usage steadily increases while the subscription is alive and repeating itself. Especially after changing the interval to 0.001 seconds instead of 1. From the Allocations instrument, it seems that the Here is the whole class so no one else has to type it in: import UIKit
import RxSwift
import RxSwiftExt
class ViewController: UIViewController {
let disposeBag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
repeatTest()
}
private func repeatTest() {
Observable.just(true)
.repeatWithBehavior(.delayed(maxCount: UInt.max, time: 0.001))
.subscribe(onNext: { _ in
print("ping")
})
.disposed(by: disposeBag)
}
} |
Here is the full project for quicker repro: RepeatTest.zip. |
Thanks your reply, do you have any idea to solve this problem? |
I tried to debug it but couldn’t immediately find a solution. I’ll see if I can find some more time but this is a bit of a packed period of time.
Shai
…On Sep 30, 2020, 6:03 AM +0300, 杨建祥 ***@***.***>, wrote:
> Here is the full project for quicker repro: RepeatTest.zip.
Thanks your reply, do you have any idea to solve this problem?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
None, sadly. All I could do is pop in and add the missing details of the issue. Perhaps as a temporary measure, you could replace repeat with an interval + flatMapFirst. |
We ran into this problem as well, leading to a stackOverflow.
|
We fixed this problem by rewriting repeatWithBehavior. This is our solution for RxSwift 5.1.1. While I'm not completely sure it doesn't leak, we were no longer seeing a clear increase in memory over time. Feel free to adapt back to official solution @freak4pc https://gist.github.com/winstondu/91da8a889ed4e42ef7b1c11951cd3edd |
Thank you! Any chance you can make a PR out of this, so it's a bit easier to review the changes you made in your rewrite? Appreciate your help! |
Unfortunately this solution is based on RxSwift 5.1.1, not the current head of RxSwift (6). We may not migrate our codebase to RxSwift 6 for a while. I can still make the PR, but only if you also make a branch and new release for RxSwiftExt 5.2 |
@freak4pc , I can't even build the repo right now. Carthage does not work for XCode 12: Carthage/Carthage#3106 |
Yup, unfortunately aware of that :( |
repeatWithBehavior has memory leak
The text was updated successfully, but these errors were encountered: