hi, my name is TAG. i using a mapview in my application and for each annotation view on the map i download image from webservice. the is that i'm not able to release all space take by the image download after make a research and create the annotation. also when i leave the viewcontroller who contain the mapview. i'm not able to release the space take by the zooming of map and all image download. Please a need help how to procede.. THX to all the community
A:
this is my code, show where i download image for annotation view:- (MKAnnotationView *)mapView:(MKMapView *)mapView1 viewForAnnotation:(id )annotation { static NSString *viewIdentifier = @"annotationView"; annView = (MKAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:viewIdentifier];
if (annView == nil) {
annView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"cell"] autorelease];
}
ParkPlaceMark *placemark1 =(ParkPlaceMark *)annotation;
AllPosts *obj_allpost;
UIButton *btn_pirate = [UIButton buttonWithType:UIButtonTypeCustom];
btn_pirate.frame=CGRectMake(8, 9, 40, 40);
btn_pirate.backgroundColor = [UIColor colorWithRed:0.897870104 green:0.897870104 blue:0.897870104 alpha:1.0];
[btn_pirate.layer setMasksToBounds:YES];
btn_pirate.layer.cornerRadius =6.0;
[btn_pirate addTarget:self action:@selector(thx:) forControlEvents:UIControlEventTouchUpInside];
int tag = 0;
int count = [arr_allposts count];
for(int j=0;j<count;j++)
{
//Post *obj_allpost = (Post *)[arr_allposts objectAtIndex:j];
//NSString *ipath = obj_allpost.ItemTitle;
if(placemark1.tag == j)
{
tag = j;
btn_pirate.tag= tag;
annView.tag =tag;
obj_allpost = [arr_allposts objectAtIndex:tag];
int serviceid = obj_allpost.ServiceId;
if(serviceid == 0)
{
[annView addSubview:btn_pirate];
annView.image = [UIImage imageNamed:@"pop_i.png"];
}
else
{
[annView addSubview:btn_pirate];
annView.image = [UIImage imageNamed:@"map_s.png"];
}
UIActivityIndicatorView *indicator1=[[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(10, 10, 20, 20)];
[indicator1 startAnimating];
indicator1.activityIndicatorViewStyle=UIActivityIndicatorViewStyleGray;
[btn_pirate addSubview:indicator1];
indicator1.tag=tag+1000;
//indicator1 = nil;
//_thread =[[NSThread alloc] initWithTarget:self selector:@selector(download:) object:btn_pirate];
//[_thread start];
NSString *str1;
if(obj_allpost.ImageURL)
{
str1 = [obj_allpost.ImageURL stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *str = [@"http://dev.winitsoftware.com/PJ/getImageForApp.aspx?W=40&H=40&image=" stringByAppendingString:str1];
str = [str stringByReplacingOccurrencesOfString:@"../" withString:@""];
HttpRequest *req =[[HttpRequest alloc]init];
[req GetRequest:str Delegate:self Tag:tag+1000 ModuleName:@"image" Button:btn_pirate ];
[req release];
}
break;
}
}
[annView addObserver:self forKeyPath:@"selected" options:NSKeyValueObservingOptionNew context:GMAP_ANNOTATION_SELECTED];
[annView setEnabled:YES];
annView.userInteractionEnabled =YES;
annView.tag = tag; //placemark.tag;
annView.canShowCallout = NO;
//CGPoint notNear = CGPointMake(10000.0,10000.0);
//annView.calloutOffset = notNear;
return annView;//[annView autorelease];
}
-(void)httpResponseReceived:(WebResponse *)response {
if(response.data)
{
[response.btn setBackgroundImage:[UIImage imageWithData:response.data] forState:UIControlStateNormal];
}
else
{
[response.btn setBackgroundImage:[UIImage imageNamed:@"cross.png"] forState:UIControlStateNormal];
}
UIActivityIndicatorView *indi=(UIActivityIndicatorView *)[response.btn viewWithTag:response.tag];
[indi stopAnimating];
[indi release];
response = nil;
[response release];
} ///this is the dealloc function : - (void)dealloc { for (id annotation in mapView.annotations) { [[mapView viewForAnnotation:annotation] removeObserver:self forKeyPath:@"selected"]; annotation = nil; [annotation release]; } [mapView release]; mapView.delegate = nil;
[btnListView release];
[btnViewTradeItem release];
[btnViewPost release];
[btnHome release];
[myView release];
[search release];
[annView release];
//[placemark release];
[allpost_obj release];
[imageView release];
[indicator release];
[_thread release];
[messageimage release];
//[ParkPlaceMark1 release];
btnListView=nil;
btnViewTradeItem=nil;
btnViewPost=nil;
btnHome=nil;
myView=nil;
search=nil;
annView=nil;
//placemark=nil;
allpost_obj=nil;
imageView=nil;
indicator=nil;
_thread=nil;
messageimage=nil;} but the problem is when i leave this view the capacity of space take by him (8MB) is not realease at all, so what maybe i'm doing wrong..THX