这是我的应用的入口 View Controller 。
它开始使用大约 6.5mb 的内存,然后以每秒大约 0.1mb 的速度不断攀升。
我到底做错了什么?
据我所知,没有任何理由可以让任何代码持续泄漏,尤其是因为它每次都运行一次。
此外,删除大部分内容似乎无济于事。想法?
//
// ViewController.m
// Paddle Jumper
//
// Created by Chance Daniel on 1/18/14.
// Copyright (c) 2014 Max Hudson. All rights reserved.
//
//#import "Flurry.h"
#import "ViewController.h"
//#import "startViewController.h"
@implementation ViewController{
BOOL sceneSetUp;
}
- (void)viewWillLayoutSubviews
{
if(!sceneSetUp){
[super viewWillLayoutSubviews];
// Configure the view
SKView * skView = (SKView *)self.view;
//skView.showsFPS = YES;
skView.showsNodeCount = YES;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if([[defaults objectForKey"firstTime"] intValue] != 1){
[defaults setObject:[NSNumber numberWithInt:1] forKey"firstTime"];
[defaults setObject"ggr" forKey"skinSelected"];
[defaults setObject:[NSNumber numberWithInt:2] forKey"ggrOwned"];
[defaults setObject:[NSNumber numberWithInt:100] forKey"gona"];
[defaults setObject:[NSNumber numberWithInt:1350] forKey"points"];
[defaults setObject:[NSNumber numberWithInt:7] forKey"livesLeftValue"];
[defaults setObject:[NSNumber numberWithInt:3] forKey"shieldsLeftValue"];
[defaults setObject:[NSNumber numberWithInt:2] forKey"lvlTwoLeftValue"];
[defaults setObject:[NSNumber numberWithInt:0] forKey:@"lvlThreeLeftValue"];
}
if(![defaults objectForKey:@"tut_game1"]){
[defaults setObject:[NSNumber numberWithInt:1] forKey:@"tut_game1"];
[defaults setObject:[NSNumber numberWithInt:1] forKey:@"tut_store"];
[defaults setObject:[NSNumber numberWithInt:1] forKey:@"tut_daily"];
}
[defaults synchronize];
// Create and configure the scene.
//SKScene * startScene = [StartViewController sceneWithSize:skView.bounds.size];
//startScene.scaleMode = SKSceneScaleModeAspectFill;
// Present the scene.
//[skView presentScene:startScene];
//[skView presentScene:scene];
sceneSetUp = YES;
}
}
-(void) switchScene{
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return UIInterfaceOrientationMaskAllButUpsideDown;
} else {
return UIInterfaceOrientationMaskAll;
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
@end
Best Answer-推荐答案 strong>
问题是你打开了僵尸。造成泄漏正是僵尸所做的! (“僵尸做什么”似乎是错误的......)它的全部目的是防止对象被释放。当僵尸(是?)打开时,您永远不应该检查内存使用情况。
关于iOS内存在app中不断增加似乎无缘无故,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/22317374/
|