How can I successfully dechiper Instruments Messages for iPhone Leak
Posted
by dubbeat
on Stack Overflow
See other posts from Stack Overflow
or by dubbeat
Published on 2010-03-25T09:00:15Z
Indexed on
2010/03/25
9:03 UTC
Read the original article
Hit count: 559
Hi,
I have a memory leak in my app. (This is the first of many I'm sure :()
I've being trying to use Instruments to find it. Instruments gives me a lot of information but I think I must just not know how to use this information.
What I did so far was
1) Run the app with Instruments 2) Memory Leak Occurs named general -stack 16 3) Find general - stack 16 in the object allocations part of instruments
4) The information here says the event type is a malloc, that webcore is responsible and the something named WKSetCurrentGraphicContext is the responsible caller.
How can I use this given information to discover where in my code the leak is being caused?
If I comment out the following function I don't get the leak warning so I guess it should be in there somewhere but I can't see where
-(void)constructFeatured
{
NSString *imageName =[[NSString alloc] initWithFormat:@"%@%@%@",@"http://myweb/avatar_", featuredValueObject.featured_promo_artistid, @".jpg"];
NSURL *url = [NSURL URLWithString:imageName];
CGRect frame;
frame.size.width=100; frame.size.height=100;
frame.origin.x=20; frame.origin.y=39;
[imageName release];
imageName=nil;
SDWebImageManager *manager = [SDWebImageManager sharedManager];
UIImage *cachedImage = [manager imageWithURL:url];
if (cachedImage)
{
cachedImage =[ImageManipulator makeRoundCornerImage:cachedImage : 10 : 10];
UIImageView *avatarimageview = [[UIImageView alloc]initWithImage:cachedImage ];
avatarimageview.frame=frame;
[self.view addSubview:avatarimageview];
UIView *spinny = [self.view viewWithTag:SPINNY_TAG];
[spinny removeFromSuperview];
[avatarimageview release];
}
else
{
[manager downloadWithURL:url delegate:self];
}
NSURL *url2 =[NSURL URLWithString:[NSString stringWithFormat:@"%@%@%@",@"http://myweb/",
featuredValueObject.featured_promo_artistcountry
, @".png"]];
CGRect flagframe;
flagframe.size.width=16; flagframe.size.height=11;
flagframe.origin.x=130; flagframe.origin.y=40;
NSData* data = [[NSData alloc] initWithContentsOfURL:url2];
UIImage* img = [[UIImage alloc] initWithData:data];
UIImageView *imageflagview = [[UIImageView alloc] initWithImage: img];
imageflagview.frame=flagframe;
[self.view addSubview:imageflagview];
[imageflagview release];
imageflagview=nil;
[data release];
[img release];
[url release];
artistname =[[UILabel alloc]initWithFrame:CGRectMake(130,75, 200, 15)];
[artistname setFont:[UIFont fontWithName:@"Arial" size:(16.0)]];
artistname.backgroundColor= [UIColor clearColor];
artistname.textColor=[UIColor whiteColor];
artistname.text=featuredValueObject.featured_promo_artistname;
[self.view addSubview:artistname];
[artistname release];
hasConstructedFeatured=YES;
[featuredValueObject release];
featuredValueObject=nil;
}
© Stack Overflow or respective owner