ios - objective c mkmapview overlay memory warning -
i developing ios park guide app displays mkmapview. show our own map have designed big size (2499x1504px) jpg overlay image. mkmapview displays view annotations.
i swiped around mapview , inspected memory size in debug navigator , recognized (sometimes, not always) memory grows 100-180 mb. if memory 150+mb memory warning , app crashes due memory problems. in simulator app never crashes.
to test purposes have removed overlays , annotations , swiped around again. in situations memory grows 100-120mb without memory warning.
my device: iphone 4s
the implementation:
if ([overlay iskindofclass:[lgsoverlay class]]) { uiimage *theimage = [uiimage imagenamed:@"overlayimage"]; xyzoverlayrenderer *overlayrenderer = [[xyzoverlayrenderer alloc] initwithoverlay:overlay overlayimage:theimage]; return overlayrenderer; }
xyzoverlayrenderer:
-(id)initwithoverlay:(id<mkoverlay>)overlay overlayimage:(uiimage *)overlayimage { self = [super initwithoverlay:overlay]; if (self) { _overlayimage = overlayimage; } return self; } - (void)drawmaprect:(mkmaprect)maprect zoomscale:(mkzoomscale)zoomscale incontext:(cgcontextref)context { cgimageref imagereferenc = self.overlayimage.cgimage; mkmaprect themaprect = self.overlay.boundingmaprect; cgrect therect = [self rectformaprect:themaprect]; cgcontextscalectm(context, 1.0, -1.0); cgcontexttranslatectm(context, 0.0, -therect.size.height); cgcontextdrawimage(context, therect, imagereferenc); }
whats best solution solve problem?
edit:
i solved problem following tutorial: http://www.shawngrimes.me/2010/12/mapkit-overlays-session-1-overlay-map/
the simulator never runs out of memory, don't think strange. jpeg images of size way big once converted video buffer. iphone 4s has 512mb of ram shared between gpu , cpu. might have find way tile image or make smaller.
how know crash due memory problems? memory warnings , app terminated? maybe there issue.
you might using more native compressed powervr format rather using jpeg. outside of opengl es i'm not sure how they're supported.
note under ios 6+ mapkit uses vectors , takes 80-100 mb display map data.
Comments
Post a Comment