Skip to content

Commit

Permalink
geopackage-ios 8.0.3 destroy and close calls for memory
Browse files Browse the repository at this point in the history
  • Loading branch information
bosborn committed Aug 24, 2023
1 parent bcd94b6 commit 661312a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions Mage/BaseMapOverlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import geopackage_ios
@objc public var darkTheme = false

@objc public func cleanup() {
super.close()
featureTiles = nil
}

Expand Down
10 changes: 10 additions & 0 deletions Mage/GeoPackage/GeoPackage.m
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ -(void) addGeoPackageCacheOverlay: (NSMutableDictionary<NSString *, CacheOverlay

SFPGeometryTransform *transform = [[SFPGeometryTransform alloc] initWithFromProjection:projection andToEpsg:PROJ_EPSG_WORLD_GEODETIC_SYSTEM];
GPKGBoundingBox * boundingBox = [contentsBoundingBox transform:transform];
[transform destroy];
boundingBox = [GPKGTileBoundingBoxUtils boundWgs84BoundingBoxWithWebMercatorLimits:boundingBox];

if(self.addedCacheBoundingBox == nil){
Expand Down Expand Up @@ -281,6 +282,9 @@ -(void) addGeoPackageTileCacheOverlay: (NSMutableDictionary<NSString *, CacheOve
cacheOverlay = nil;
} else {
// remove the old one and it will be re-added to preserve layer order
if ([tileTableCacheOverlay.tileOverlay isKindOfClass:[GPKGBoundedOverlay class]]){
[((GPKGBoundedOverlay *)tileTableCacheOverlay.tileOverlay) close];
}
[self.mapView removeOverlay:tileTableCacheOverlay.tileOverlay];
cacheOverlay = nil;
}
Expand All @@ -293,6 +297,9 @@ -(void) addGeoPackageTileCacheOverlay: (NSMutableDictionary<NSString *, CacheOve
[tileTableCacheOverlay setTileOverlay:geoPackageTileOverlay];

// Check for linked feature tables
for (GPKGFeatureOverlayQuery *query in tileTableCacheOverlay.featureOverlayQueries) {
[query close];
}
[tileTableCacheOverlay.featureOverlayQueries removeAllObjects];
GPKGFeatureTileTableLinker * linker = [[GPKGFeatureTileTableLinker alloc] initWithGeoPackage:geoPackage];
NSArray<GPKGFeatureDao *> * featureDaos = [linker featureDaosForTileTable:tileDao.tableName];
Expand Down Expand Up @@ -333,6 +340,7 @@ -(void) addGeoPackageTileCacheOverlay: (NSMutableDictionary<NSString *, CacheOve
[tileTableCacheOverlay removeFromMap:weakSelf.mapView];
}
if (geoPackageTileOverlay != nil) {
[geoPackageTileOverlay close];
[weakSelf.mapView removeOverlay:geoPackageTileOverlay];
}
});
Expand Down Expand Up @@ -468,6 +476,7 @@ -(void) addGeoPackageFeatureCacheOverlay: (NSMutableDictionary<NSString *, Cache
}
@finally {
[resultSet close];
[shapeConverter close];
}
}

Expand All @@ -494,6 +503,7 @@ -(void) addGeoPackageFeatureCacheOverlay: (NSMutableDictionary<NSString *, Cache
[featureTableCacheOverlay removeFromMap:weakSelf.mapView];
}
if (featureOverlay != nil) {
[featureOverlay close];
[self.mapView removeOverlay:featureOverlay];
}
});
Expand Down
1 change: 1 addition & 0 deletions Mage/Map/Cache/GeoPackageFeatureTableCacheOverlay.m
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ -(GPKGFeatureTableData *) getFeatureTableDataWithLocationCoordinate: (CLLocation
SFPGeometryTransform *transform = [[SFPGeometryTransform alloc] initWithFromProjection:self.featureOverlayQuery.featureTiles.featureDao.projection andToEpsg:4326];

centroid = [transform transformPoint:centroid];
[transform destroy];
coordinate = CLLocationCoordinate2DMake([centroid.y doubleValue], [centroid.x doubleValue]);
}
[featureDataTypes setValue:[GPKGDataTypes name:featureRow.featureColumns.columns[i].dataType] forKey:columnName];
Expand Down
1 change: 1 addition & 0 deletions Mage/Map/MapObservationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ -(MapObservation *) addToMapWithObservation: (Observation *) observation withGeo

GPKGMapShapeConverter *shapeConverter = [[GPKGMapShapeConverter alloc] init];
GPKGMapShape *shape = [shapeConverter toShapeWithGeometry:geometry];
[shapeConverter close];
switch(shape.shapeType){
case GPKG_MST_POLYLINE:
{
Expand Down
1 change: 1 addition & 0 deletions Mage/Mixins/FilteredObservationsMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class FilteredObservationsMapMixin: NSObject, MapMixin {
let style = ObservationShapeStyleParser.style(of: observation)
let shapeConverter = GPKGMapShapeConverter()
let shape = shapeConverter?.toShape(with: geometry)
shapeConverter?.close()

if let mkpolyline = shape?.shape as? MKPolyline {
let styledPolyline = StyledPolyline.create(polyline: mkpolyline)
Expand Down
1 change: 1 addition & 0 deletions Mage/Mixins/SFGeometryMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class SFGeometryMapMixin: NSObject, MapMixin {
}
let shapeConverter: GPKGMapShapeConverter = GPKGMapShapeConverter()
let shape = shapeConverter.add(sfGeometry, to: mapView)
shapeConverter.close()
geometryToShape[sfGeometry] = shape
}

Expand Down

0 comments on commit 661312a

Please sign in to comment.