【问题标题】:Every time I tap using UITapGestureRecognizer memory usage increase. why?每次我点击使用 UITapGestureRecognizer 时,内存使用量都会增加。为什么?
【发布时间】:2013-05-24 12:27:31
【问题描述】:

我刚刚使用 xcode 创建了一个“单视图应用程序”,并添加了一个 UITapGestureRecognizer 在“viewDidLoad”方法中。 然后我用仪器监控内存分配,每次我点击分配的内存增加的大小。如果尝试点击几次内存使用量会增加。 为什么会有这种行为?

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
    [self.view addGestureRecognizer:tapGesture];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)handleTap:(UIGestureRecognizer *) sender
{
   // NSLog(@"....");
}

【问题讨论】:

    标签: memory profiler uitapgesturerecognizer


    【解决方案1】:

    对此我不确定,但我认为是因为系统的内存是动态分配的,所以当它意识到它需要更多来处理按钮动作时,它会使用更多的内存

    【讨论】:

    • 好的,但是如果我点击 100 次......内存会按比例增加。有没有可能面临“无限内存增长”的问题?
    • 如果你等几分钟它不会下降?
    猜你喜欢
    • 2011-08-28
    • 2011-01-18
    • 1970-01-01
    • 2017-04-14
    • 1970-01-01
    • 1970-01-01
    • 2019-05-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多