Dans mon projet iPhone quand je choisis construire et analyser (shift + mac + A) il me donnera toute fuite de mémoire potentielle dans mon projet ... mais dans mon projet actuel, il n'est pas travailler ... quand je mets volontairement une fuite de mémoire et sélectionnez la construction et ... il n'analyser me donne pas une fuite de mémoire comme résultat de l'analyseurconstruire et analyser ne fonctionne pas dans mon projet
si j'écris
NSMutableArray *tempArray = [[NSMutableArray alloc] initWithCapacity:6];
NSMutableArray *tempArrayfinal = [[NSMutableArray alloc] initWithCapacity:12];
et qui ne fonctionne pas relâchez-le ... il ne me donne aucune fuite potentielle mais si j'écris
NSString *leakyString = [[NSString alloc] initWithString:@"Leaky String "];
NSLog(@"%@",leakyString);
ici il me donne la fuite potentielle comme résultat d'analyseur ... pourquoi il ne donne pas la fuite potentielle dans NSMutableArray et pourquoi il donne la fuite potentielle dans NSString? ... comment puis-je compter sur Construire et analyser pour la fuite de mémoire ...
J'ai couru l'application avec l'outil de fuite et elle manifeste me fuite dans tempArray
et tempArrayfinal
Voici ma fonction
- (void)viewDidLoad
{
[super viewDidLoad];
maxOnSnaxAppDelegate *delegate = (maxOnSnaxAppDelegate *)[[UIApplication sharedApplication] delegate];
lblMessage.tag = MESSAGE_LABEL;
lblGuess.tag = GUESS_LABEL;
lblScore.tag = SCORE_LABEL;
self.gameCompleteView.tag = FINAL_SCORE_VIEW;
lblFinalScore.tag = FINAL_SCORE_LABEL;
lblGuess.text = @"";
lblMessage.text = @"";
lblScore.text = @"";
int row = 0;
int column = 0;
maxImagrArray = [[NSMutableArray alloc] init];
for(UIView *subview in [self.view subviews]) {
if([subview isKindOfClass:[CustomImageView class]])
{
[subview removeFromSuperview];
}
}
for(int i = 0 ; i < 12 ; i++)
{
if(i%3 == 0 && i != 0)
{
row++;
column = -1;
}
if(i != 0)
{
column++;
//row = 0;
}
CustomImageView *tempImageView = [[CustomImageView alloc] initWithImage:[UIImage imageNamed:@"max-img.png"]];
tempImageView.frame = CGRectMake((column*tempImageView.frame.size.width) + 45, (row*tempImageView.frame.size.height)+ 60, tempImageView.frame.size.width, tempImageView.frame.size.height);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClearRect(context, tempImageView.bounds);
[self.view addSubview:tempImageView];
tempImageView.tag = i+1;
tempImageView.userInteractionEnabled = YES;
[maxImagrArray addObject:tempImageView];
[tempImageView setIndex:i];
[tempImageView release];
}
NSMutableArray *tempArray = [[NSMutableArray alloc] initWithCapacity:6];
NSMutableArray *tempArrayfinal = [[NSMutableArray alloc] initWithCapacity:12];
for(int i = 0 ; i < 12 ; i++)
{
if(i < 6)
{
int temp = (arc4random() % 10) + 1;
NSString *tempStr = [[NSString alloc] initWithFormat:@"%d",temp];
[tempArray insertObject:tempStr atIndex:i];
[tempArrayfinal insertObject:tempStr atIndex:i];
[tempStr release];
}
else
{
int temp = (arc4random() % [tempArray count]);
[tempArrayfinal insertObject: (NSString *)[tempArray objectAtIndex:temp] atIndex:i];
//int index = [(NSString *)[tempArray objectAtIndex:temp] intValue];
[tempArray removeObjectAtIndex:temp];
}
CustomImageView *tmpCustom = [maxImagrArray objectAtIndex:i];
tmpCustom.frontImageIndex = [(NSString *)[tempArrayfinal objectAtIndex:i] intValue];
NSLog(@"%d",tmpCustom.frontImageIndex);
}
[maxImagrArray release];
delegate.time = 60.0;
timer = nil;
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countDown) userInfo:nil repeats:YES];
delegate.view = self.view;
//[tempArray release];
//[tempArrayfinal release];//these 2 lines are deliberately commented to see
//...it is not showing any potential memory leak though....
delegate.viewController = self;
}
s'il vous plaît aider ...
Avez-vous essayé le vérifier est une réelle fuite de mémoire en utilisant Run -> Exécuter w/Performance Tools -> outil de fuites? la plupart du temps Apple obtient ces choses correctement donc il est probablement un problème avec votre code – iwasrobbed
oui j'ai vérifier en utilisant les outils de fuite tempArray et tempArrayfinal fuit réellement mais ne montre pas comme fuite potentielle en construction et analyse ... –