IOS app memory usage continues to grow in Xcode

I am new to iOS programming, and I just created an iPhone application that can ask the user a question and return an answer. Building Environment - OS X 10.9 and Xcode 5.0.2. Every time I launch an iPhone simulator, Debug Navigator shows that the memory usage is 13.5 MB, but it continues to grow even after I return to the main screen. After a minute, memory usage is stabilized by about 17.5 mb. Is this normal behavior or do I need to add memory management code?

#import "QuizViewController.h"

@interface QuizViewController ()

@property (nonatomic) int currentQuestionIndex;
@property (nonatomic, copy) NSArray *questions;
@property (nonatomic, copy) NSArray *answers;

@property (nonatomic,weak) IBOutlet UILabel *questionLable;
@property (nonatomic,weak) IBOutlet UILabel *answerLable;

@end

@implementation QuizViewController

- (instancetype) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if(self){
        self.questions = @[@"From what is cognac made?",
                           @"What is 8 + 8 ?",
                           @"What is the capital of Minnesota?"];
        self.answers = @[@"Grapes",
                         @"16",
                         @"St.Paul"];
    }

    return self;
}

- (IBAction)showQuestion:(id)sender
{
    self.currentQuestionIndex++;
    if (self.currentQuestionIndex == [self.questions count]){
        self.currentQuestionIndex = 0;
    }
    NSString *question = self.questions[self.currentQuestionIndex];
    self.questionLable.text = question;
    self.answerLable.text = @"???";
}
- (IBAction)showAnswer:(id)sender
{
    NSString *answer = self.answers[self.currentQuestionIndex];
    self.answerLable.text = answer;
}

@end
+4
source share
1 answer

ARC. ? , . , , .

+1

Source: https://habr.com/ru/post/1530891/


All Articles