-
Notifications
You must be signed in to change notification settings - Fork 260
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 when configuring amplify #5161
Comments
Hi @kamami, Typically, we recommend using
If not, can you further explain your use case for calling |
Hi @Equartey , I think using Amplify in an additional entry point ( BTW. using the same approach with Firebase/Firestore is working perfectly fine. The multiple initializations of Firebase are not causing any problems.
|
Thank you for the context, that's really helpful. Couple comments and questions:
|
![]() The red errors show the time when |
Hi @kamami, we're working on reproducing this to validate some assumptions. In the meantime, we suspect that each call to If this hypothesis is correct, calling |
The point when my business logic is done, is not always clear. The
|
@kamami I've been unsuccessful with my attempts to observe a consistent memory increase like the graph you shared. I've seen memory usage spike, but it returns to base line after a few seconds. Given the challenge of recreating this environment, offering more specific steps or a sample app could be beneficial. Ultimately, until we have official support for making multiple calls to
|
From offline discussions, it sounds like the issue here is caused by configuring Amplify from multiple isolates. This is not something we officially support. We use The best solution here is probably to find a way to only configure and call Amplify on a single isolate (ideally the main isolate). I think you could could use a receive port and send port to send messages between the main isolate and the new isolate that is spun up each time. Please see https://dart.dev/language/isolates#sending-multiple-messages-between-isolates-with-ports. As for the differences between Firebase and Amplify - I cannot speak in detail about Firebase, but at a high level Firebase in Flutter is just a wrapper around a set of native iOS/Android/JS Firebase libraries. It likely doesn't matter how many Dart isolates you spin up since there is likely very little resources consumed on the dart side. Amplify Flutter is written primarily in Dart. Native code is only invoked when needed to interact with native APIs. We favor a dart first approach since it allows us to support all platforms that Flutter supports, ensures consistent behavior across those platforms, is the language that most of our customers are most familiar with, and it makes debugging much simpler. Let us know if you have any questions. |
@kamami - Let me know if you have any further questions, or if you are interested in opening a feature request to track official support for using Amplify from multiple isolates. |
Description
I am configuring amplify in a function, which is called multiple times by native code while the app is running. It is designed to track the users location even in the background. I also want to access my API Gateway and Authentication Services there to send the GPS data to my AWS backend.
I am observing following:
When calling
_configureAmplify
I get a permanent increased memory usage on my iPhone 15 pro. When call_configureAmplify
, but without the linesawait Amplify.addPlugins([authPlugin, apiPlugin]);
I do not get an increased memory usage. But this is not an option, because I need those plugins.Categories
Steps to Reproduce
Run
_configureAmplify
with and withoutawait Amplify.addPlugins([authPlugin, apiPlugin]);
Screenshots
This is the chart, when adding both plugins before configuration. Every step is one invocation of
backgroundCallbackDispatcher
.This is the chart, when NOT adding both plugins before configuration.
Platforms
Flutter Version
3.22.2
Amplify Flutter Version
2.2.0
Deployment Method
Amplify CLI
Schema
No response
The text was updated successfully, but these errors were encountered: