0

I was solving my app's memory leak problem, I narrowed the scope, and found out the "leak" (instruments didn't say leak, but memory went up) came from this method:

- (void)loadDataSource
{
    self.enLabel.text = self.dataSource.en;  // English words
    self.cnLabel.text = self.dataSource.cn;  // Chinese translation
}

The app is a flash cards app. Swipe to switch to next card. Tap to see answer(cnLabel.hidden = NO).

It has only 2 CardView, when prepareing next card, cardView.dataSource will be set, and call this method "loadDataSource".

I did some experiments (50 switch per experiment) on my iphone4:

  1. Baseline: With every switch, the memory went up( ~0.02M per switch );
  2. "return;" at the beginning: memory was OK;
  3. only set enLabel.text: memory was OK;
  4. only set cnLable.text: memory went up;
  5. set cnLabel.text to random NSString made from 8 Chinese characters: memory is OK;

So it seems that the framework reserved something for every different Chinese character.

So my question: Is this normal, or did I just miss something ?

4

0 回答 0