'Flutter iOS version app crashed due to consuming high memory
I have developed a flutter app using the Bloc pattern. Everything was fine until we encountered a memory crash in iOS. The Android version works well without any memory issues. But the iOS version of the app does have a memory issue. The memory is kept on accumulating when navigating to another page or for every background sync by staying at the same page (increasing memory even without navigation). Eventually, the app CRASHES due to the “Terminated due to memory issue” in the Xcode console. I have tried:
- Closing the streams
- Optimising the code
- Closing all the blocs.
- Used Xcode Instruments to see the memory heap (It shows memory leaks but not much info available about any methods or objects that are retained.)
- Used Dart DevTools to profile the app. Still, not much info is available.
- Used ‘Observatory’ to see whether the memory is accumulating in any specific area. But no use.
The Android version is working perfectly. What could be the problem for iOS only? Do we need to do something else in flutter explicitly, to free up the memory in iOS? Since I am closing the blocs and streams, ideally the memory should be disposed of while closing them right? See the attached screenshot which shows the memory heap in Xcode.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|