Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is that you are never removing the UILabel from the Status UIView. Let's take a look at your retain counts in drawRect:</p> <pre><code>(void)drawRect:(CGRect)rect { title =[[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 12.0f)]; </code></pre> <p>Here, you have created a UILabel with alloc, which creates an object with a retain count of 1.</p> <pre><code>[self addSubview:title]; [title release]; </code></pre> <p>Adding the UILabel to Status view increases title's retain count to 2. The following release results in a final retain count of 1. Since the object is never removed from its superview, the object is never deallocated.</p> <p>Essentially, you are adding one UILabel on top of another, each time the timer is fired, until memory runs out. </p> <p>As suggested below, you should probably create the UILabel once when the view loads, and just update the UILabel's text with [model n].</p> <p>As a housekeeping note, you might also want to make sure that you are properly deallocating any left over objects in your dealloc methods. 'model' and 'title' should be released in Status' dealloc, just as 'model' should be in SbarLeakAppDelegate.</p> <p>Hope this helps.</p> <p>Edit [1]:</p> <p>It sounds like you have the memory issue pretty well handled at this point. I just wanted to suggest another alternative to the two timers you are using. </p> <p>The timer you have running in your Status object fires every .2 seconds. The timer which actually increments the 'model' value, n, fires only once each second. While I believe you are doing this to ensure a more regular "refresh rate" of the Status view, you are potentially re-drawing the view 4 or 5 times per second without the data changing. While this is may not be noticeable because the view is fairly simple, you might want to consider something like NSNotification.</p> <p>With NSNotification, you can have the Status object "observe" a particular kind of notification that will be fired by the Model whenever the value 'n' changes. (in this case, approximately 1 per second). </p> <p>You can also specify a callback method to handle the notification when it is received. This way, you would only call -setNeedsDisplay when the model data was actually changed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload