-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
google_maps_flutter Memory Leak when map is shown, memory allocated never dispose #35243
Comments
have the same critical issue even with the emulator |
Same issue with our app. RAM usage goes above a GB over time. |
Same issue here, while using the map memory just keeps rising, at some point the map freezes. I have been struggling with this, and it makes me doubt about the Flutter concept. |
@amirh would know how to route this. |
Any rough ETA of a fix on this? This is main block for us from going into prod. |
Just as an addition, this seems to be on both platforms, not just iOS. For us, it is taking up more memory by the minute and then rebooting some Android phones completely, whereas iOS shuts the app down once it goes above a certain value. We rechecked for any recursive code that might be causing this same bug as well. We also removed maps to confirm and it does not seem to be happening anymore. |
It looks like this is assigned, but not scheduled. Do we have a reduction/example we could offer the team? Or does any usage of maps produce this? Thanks. |
@eseidel Any implementation of maps causes this for us currently. Another flavor of the app without the map works perfectly without memory issues. |
@iskakaushik has been busy with other work the last month or more. We should probably un-assign this and find a new owner. |
I'm also having the same problem, map never releases the allocated memory |
Any update on this memory leak issue for google map flutter plugin in iOS devices? This is affecting our production release plan |
Same issue here. |
To anyone who has this as blocker: I'd recommend temporarily replacing Google maps with the mapbox implementation - https://pub.dev/packages/flutter_map |
Facing same memory leak issue in iOS devices. |
Hi @deven98 |
@boominadhaprakash Tbh, we just needed markers for our app, but I did see code in the package for pretty much everything you mentioned, so do check it out. Solved our use cases. |
@deven98 Okay, thank you. I will check. |
is anyone working on this critical issue? |
I was also wondering if anyone's working on this? Our iOS app crashes after using for couple of minutes because of this memory leak |
same here... |
is this an issue with google maps plugin or flutter platform views? dealloc is getting called for the FLTGoogleMapController Obc class. I tried to clear map. Tried below but no luck -(void)dealloc {
NSLog(@"FLTGoogleMapController dealloc");
[_mapView clear];
_mapView.delegate = nil;
_mapView = nil;
_markersController = nil;
_polygonsController = nil;
_polylinesController = nil;
_circlesController = nil;
_registrar = nil;
} Below code change in GoogleMapController.m reduced memory leak. we have 2 map screens, switching them 5-7 times made the app crash before, now it take 50+ - (NSObject<FlutterPlatformView>*)createWithFrame:(CGRect)frame
viewIdentifier:(int64_t)viewId
arguments:(id _Nullable)args {
static FLTGoogleMapController *fltVC = nil;
if(fltVC) {
[fltVC clearMapData];
[fltVC addMarkersController:args];
[fltVC addPolygonsController:args];
[fltVC addPolylinesController:args];
[fltVC addCirclesController:args];
}
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
fltVC = [[FLTGoogleMapController alloc] initWithFrame:frame
viewIdentifier:viewId
arguments:args
registrar:_registrar];
});
return fltVC;
/*return [[FLTGoogleMapController alloc] initWithFrame:frame
viewIdentifier:viewId
arguments:args
registrar:_registrar];*/
} |
@adar2378 Replace below files in the plugin folder Added clearMapView(); API in controller.dart. Call it before you switch to different map view @override
void dispose() {
mapController.clearMapView();
super.dispose();
}
|
@kattaliraees is there any chance to add this fix directly in the package and the rest of users just update it directly from pubspec.yml ? Either the way many thanks for this solution |
@durduliu2009 we cannot consider this as an actual fix. This is a temporary workaround to reduce the quantity of memory getting leaked. Also not sure if this have any impact on anywhere else. But it works fine for our scenario. We are keeping an entire copy of plugin folder within our source code repository and referring to that in pubspec.yaml google_maps_flutter:
path: ./lib/google_maps_flutter-0.5.21+11 |
Thank you so much :) |
This change work for me. but it is not totally release all memory that map alloc, but it can release most. Below code change in GoogleMapController.m
|
I've tried it and I receive a message in debug console (tried meaning: copy google maps plugin into my local folder lib .. in that new folder from lib I've replaced files from the archive )
pubspec.yml
|
@durduliu2009 the clearMapView platform method is only added for iOS. So if you try to call it from the android build, it will give you the error. If the platform is android, don't call the clearMapView API. If you getting the error from the iOS build, try to clean and build and also make sure the files are replaced |
Also, remove the example folder from the plugin folder |
I'm running this for android. So for android there is still memory leak and just for iOS exist that small workaround ? Many thanks in advance |
I didn't find the memory leak on android though. @durduliu2009 |
flutter/engine#14326 |
@kattaliraees @darkmarthur Do you still experience a huge amount of leaks using flutter on master? |
@cyanglaz switching between 2 maps screens 10 times in iOS Simulator. On-device it will crash once it crosses 1GB |
@kattaliraees I also saw the big memory leak on simulator, but on real device, it seems to be better. Have you checked it on real devices? |
@cyanglaz Currently don't have a device with me. But will check and let you know soon |
@cyanglaz I can confirm that there is no memory leak on iOS Devices (verified on iPad 5th Gen iOS 13.3). It never crossed more than 450MB. Cheers 👏 |
So we need to update to the latest version of flutter for this fix? |
@adar2378 The fix is not available in stable channel(which is the default). You have to switch to the master channel by running below
|
@kattaliraees Thanks for confirming. I am going to close this issue since the original post is about leaking in the real device. @darkmarthur please reply if you found the issue not fixed and we can reopen and take a look again. |
@cyanglaz so do I need to change the channel from stable to master to resolved this memory issue? |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to Reproduce
Problem:
I have been facing a critical issue with the GoogleMap plugin, the problem is on iOS devices, when the GoogleMap widget is RENDERED (please note that the problem is not when instantiating the object) it appends a lot of memory to the current app, when the map is disposed, that memory allocated never goes away, it keeps growing as the Map is called to be shown.
Why it is a critical issue:
This is a critical issue because on iOS when the app reaches approximately 1gb the OS closes the app unexpectedly, and its a blocker to launch our app to production.
Replicate:
Use the memory monitor of XCode, not the dart tools,
This is not replicable on the emulator, only on real iOS devices, you can use the google_maps_flutter example to test.
Request:
Please let us know if you can replicate the issue just to be sure that this is on your scope
Evidence:
Video from the google_maps_flutter example performance
https://drive.google.com/open?id=1c78VJhBYsKc8HRX-8_RiR56J1LHnoWvJ
The text was updated successfully, but these errors were encountered: