[英]Google Maps SDK for iOS keeps increasing usage of memory
我已經構建了一個在地圖上顯示標記的簡單應用程序,我從服務器的JSON文件加載其x,y,標記是可點擊的,所以一旦你在任何標記上它將你帶到另一個UIViewController
(我們將它命名為BViewController
) 。 我已經監視了內存使用情況,所以每次我從BViewController
到MapViewController
(里面的地圖)時,它只是內存使用量的兩倍我嘗試將其設置為nill
或從superView
刪除它,但沒有改變
我的項目使用ARC 。
所以請知道如何減少這種用法。
提前致謝
我不能在沒有看到更多代碼的情況下立即告訴導致這種情況的原因,但是對於像GMSMapView這樣的“昂貴”對象,我可能會創建一個類別來創建共享GMSMapView並以編程方式添加它,如果您還沒有這樣做的話。 您的類別可能如下所示:
// GMSMapView+MyAdditions.h
#import <GoogleMaps/GoogleMaps.h>
@interface GMSMapView (MyAdditions)
+ (GMSMapView *)sharedMapView;
@end
// GMSMapView+MyAdditions.m
#import "GMSMapView+MyAdditions.h"
@implementation GMSMapView (MyAdditions)
+ (GMSMapView *)sharedMapView {
static GMSMapView *mapView;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
CLLocation *location = [[CLLocation alloc] initWithLatitude:40.7127 longitude:-74.0059];
GMSCameraPosition *cameraPosition = [GMSCameraPosition cameraWithLatitude:location.coordinate.latitude
longitude:location.coordinate.longitude
zoom:16.0];
mapView = [GMSMapView mapWithFrame:[UIScreen mainScreen].bounds camera:cameraPosition];
});
return mapView;
}
@end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.