• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
iOS - Help with nasty memory leak
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

iOS - Help with nasty memory leak


  • Subject: iOS - Help with nasty memory leak
  • From: Philip Vallone <email@hidden>
  • Date: Sat, 27 Nov 2010 09:33:59 -0500

Hi,

I have implemented a dragable annotation in my app. I am getting a 100% memory leak that has me puzzled. I was hoping that someone can provide some guidance. The leak is at:

MKAnnotationView *draggablePinView = [[[AnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"PinIdentifier"] autorelease];

Here is the entire method:

- (MKAnnotationView *)mapView:(MKMapView *)MapView viewForAnnotation:(id <MKAnnotation>)annotation
{

	MKAnnotationView *draggablePinView = [[[AnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"PinIdentifier"] autorelease];

	if (draggablePinView) {
		draggablePinView.annotation = annotation;

	} else {


		if ([draggablePinView isKindOfClass:[AnnotationView class]]) {

			((AnnotationView *)draggablePinView).mapView = MapView;

		}
	}

	((MKPinAnnotationView *)draggablePinView).pinColor = MKPinAnnotationColorGreen;
	((MKPinAnnotationView *)draggablePinView).animatesDrop = YES;


	return draggablePinView;
}


The analizer says the leak is AnnotationView. So I can't see anything in AnnotationView that would cause the leak:

#import "AnnotationView.h"
#import "CurrentLocationAnnotation.h"

@implementation AnnotationView
@synthesize hasBuiltInDraggingSupport;
@synthesize mapView;

- (void)dealloc {

	    [super dealloc];
}

- (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier {

	self.hasBuiltInDraggingSupport = [[MKPinAnnotationView class] instancesRespondToSelector:NSSelectorFromString(@"isDraggable")];

	if (self.hasBuiltInDraggingSupport) {
		if ((self = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIdentifier])) {
			[self performSelector:NSSelectorFromString(@"setDraggable:") withObject:[NSNumber numberWithBool:YES]];
		}
	}


	self.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
	self.canShowCallout = YES;


	UIImage *image = [UIImage imageNamed:@"gps_add.png"];
	UIImageView *imgView = [[[UIImageView alloc] initWithImage:image] autorelease];
	self.leftCalloutAccessoryView = imgView;
	self.image = image;

    return self;
}


@end

Thanks for any help and guidance.

Phil_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: iOS - Help with nasty memory leak
      • From: Joar Wingfors <email@hidden>
  • Prev by Date: Re: How to encrypt a String to a SHA-1 Encrypted in iPhone
  • Next by Date: OutlineView with big text editor
  • Previous by thread: Re: How to encrypt a String to a SHA-1 Encrypted in iPhone
  • Next by thread: Re: iOS - Help with nasty memory leak
  • Index(es):
    • Date
    • Thread