Skip to content
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

自定义ImageDownloader时可能造成内存泄露 #235

Closed
dopcn opened this issue Feb 15, 2016 · 1 comment · Fixed by #236
Closed

自定义ImageDownloader时可能造成内存泄露 #235

dopcn opened this issue Feb 15, 2016 · 1 comment · Fixed by #236
Assignees

Comments

@dopcn
Copy link
Contributor

dopcn commented Feb 15, 2016

在 ImageDownloader 里 session 是一个 strong property
private var session: NSURLSession?
在 ImageDownloader 的 init 里

session = NSURLSession(configuration: sessionConfiguration, delegate: self, delegateQueue: NSOperationQueue.mainQueue())

NSURLSession 的文档提到

IMPORTANT
The session object keeps a strong reference to the delegate until your app exits or explicitly invalidates the session. If you do not invalidate the session by calling the invalidateAndCancel or finishTasksAndInvalidate method, your app leaks memory until it exits.

defaultDownloader 是不会 deinit 的单例所以不影响,但是如果自定义 ImageDownloader 有可能会造成内存泄露

@onevcat
Copy link
Owner

onevcat commented Feb 15, 2016

Should be fixed in #236

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants