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

Possible memory leak #12

Open
saormart opened this issue Feb 20, 2020 · 2 comments
Open

Possible memory leak #12

saormart opened this issue Feb 20, 2020 · 2 comments

Comments

@saormart
Copy link

In the example project, if add the "deinit" on "class CropController: DocumentCropController".
After you do the process to crop image etc, and go back to the "ScannerController" the class "CropController" never call the "deinit". And using instruments, I notice a possible memory leak!
Thanks!

@saormart
Copy link
Author

I was able to track and fix the memory leak issue!
1st: To fix the issue with the "deinit" never been called, we need to change the Outlet imageView var to weak var. Follow the class name and the corrected var:
open class DocumentCropViewController: UIViewController { ... @IBOutlet public weak var imageView: UIImageView!

Another change to get the "deinit" to finally work, I made a workaround, and it's welcome if there's a better way to fix it, so follow the class and the function name that I added the follow lines at the end:
`public final class VisionImageRectangleDetector: ImageRectangleDetector {
.....
private func handleRequest(request: VNRequest, error: Error?) {
.....

let when = DispatchTime.now() + 1 //Change the 1 to desired number in seconds
DispatchQueue.main.asyncAfter(deadline: when){ [unowned self] in
self.completionHandler = nil
}`

And finally to fix the memory leak issue:
public class SECropView: UIView { .... fileprivate weak var imageView : UIImageView?

Hope this helps!

@saormart
Copy link
Author

saormart commented Mar 6, 2020

And there's another memory leak issue related to the CropView framework that was holding the picture in memory in the class "SECropView" "imageView", and I open a ticket in here

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

No branches or pull requests

1 participant