UILabel memory leak?

后端 未结 2 1758
别那么骄傲
别那么骄傲 2021-01-17 07:21

I have an NSTimer that fires off every second, and on that second I update a UILabel by setting the text property like so:

remainglbl.text = [NSString string         


        
相关标签:
2条回答
  • 2021-01-17 07:28

    Just out of curiosity, does the problem still occur if you use [remainingLbl setText: ] instead of setting the property? Your code looks fine... the memory should be cleaned up since stringWithFormat autoreleases the string.

    One other thing to try: when you create threads in Objective-C you have to wrap all the code in an NSAutoreleasePool so that the things you create during the thread's execution are cleaned up. That shouldn't make a difference here as one should already exist - but it's worth a shot.

    0 讨论(0)
  • 2021-01-17 07:52

    I believe the problem was that I did not understand the performance tools. Running with the Activity Monitor does not show increasing memory usage.

    0 讨论(0)
提交回复
热议问题