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

Memory Leak #249

Open
flbaue opened this issue Jun 14, 2023 · 3 comments
Open

Memory Leak #249

flbaue opened this issue Jun 14, 2023 · 3 comments

Comments

@flbaue
Copy link

flbaue commented Jun 14, 2023

I have an app in witch I show the PDFView inside a PageView.builder. This allows the user to swipe left and right between multiple documents. After swiping lots of documents, the app gets terminated because of too much memory consumption (iOS).

The memory view from the dart dev tools shows me that all the PDFView instances are still retained by their PDFViewController.

I have added a dispose method to the _PDFViewState that calls dispose on the controller and sets the reference to null. Inside the controller I added a dispose method that sets the methodCallHandler to null, the channel to null and the widget to null.

With these changes the PDFView does not get retained and disappears from the memory.

@dfalmeida
Copy link

I can confirm I'm also getting multiple PDFView instances and I did manage to get 0 instances with your solution @flbaue.
But now I'm facing a memory leak on iOS native classes:
image

@flbaue
Copy link
Author

flbaue commented Jul 28, 2023

@dfalmeida yes, I also noticed that and it still causes the app to crash. But I did not find a solution so far.

@dfalmeida
Copy link

dfalmeida commented Aug 1, 2023

@flbaue I think I've found a quick fix, not the ideal but it frees the memory.
Under the file FlutterPDFView.m inside the @implementation FLTPDFView add a new method:

- (void)removeFromSuperview {
  _controler = nil;
  _pdfView = nil;
}

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

2 participants