Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective C: What does allocation 'count' mean (using instruments)

I ran my app using Instruments and found that one of my methods' [UICustomButton loadButton..]" count under allocation is always increasing (see screenshot below) -

enter image description here

The method in question is triggered whenever I scroll a tableview and when the cell is visible.

My questions are

1) What does the count actually mean? Is it normal for it to keep increasing?

2) Is the increasing count the reason why my scrolling becomes increasingly laggy?

like image 219
Zhen Avatar asked Oct 10 '22 14:10

Zhen


1 Answers

The count in the instruments show the number of instances of a given class your application has created that are stil alive. So it is normal to increase up to the point where your application has created all the objects it needs to have, then it should remain more or less constant (more or less because you will be probably creating and releasing objects all the time).

If the count never stops increasing you probably leak objects - create and not release properly. This may lead to slow down (if you are creating performance expensive objects or have to work with all the instances which are getting more and more for example), it will definitely lead to crash after you've used more memory that your app is allowed to use.

Did you reuse cells in tableView? You should, otherwise you'll get this very effect: increasing instance count, increasing memory usage, slow scrolling and crash after the time.

like image 116
Tomasz Stanczak Avatar answered Nov 28 '22 17:11

Tomasz Stanczak