开发者

UITableView memory management

开发者 https://www.devze.com 2023-02-08 07:33 出处:网络
can someone please clarify th开发者_高级运维is: when a table cell scrolls off the screen, does it still reside in memory? The reason why I am asking this is, I had to use a tableview that has to handl

can someone please clarify th开发者_高级运维is: when a table cell scrolls off the screen, does it still reside in memory? The reason why I am asking this is, I had to use a tableview that has to handle too many cells. when you scroll the table up, it loads next set of visible cells. At this point, i want to make sure , that all the cells thats been scrolled off, wont be added as a heap slowing the performance. Thanks,


If you queue the cells then each cell, as soon as it disappears from the screen (that is, it is scrolled up or down), is re-used for other new cells entering in the screen. This means that if your screen can show no more than 7 cells at the moment, the memory taken for cell allocations will not be higher than the one needed for exactly 7 of them. The advantage of this approach is memory saving but also performance improvement as you don't need to alloc/init the cells each time.

Of course this is valid if you appropriately autorelease cells when created, if you use the same queue identifier and of course it is independent on your way to manage the data you will insert in the queue (images, strings, ...)

0

精彩评论

暂无评论...
验证码 换一张
取 消