简体   繁体   中英

UITableView insertSections Memory Leak

I have a table which content I fetch remotely while showing a modal "Loading..." head up display, then I present the table when the content is ready by inserting the sections with animation:

[self.tableView insertSections:[NSIndexSet indexSetWithIndexesInRange:
                                     NSMakeRange(0, tableSectionsCount)]
                   withRowAnimation:UITableViewRowAnimationFade];

Inspecting this in Instruments shows a footprint in the VM: CoreAnimation for about 2.78 MB. This footprint stays there forever!

When replacing the code above with a simple [self.tableView reloadData]; I have no memory leaks at all. Although it is just ugly to do reload the table without animation.

Also replacing the UITableViewRowAnimationFade with other animations or even with UITableViewRowAnimationNone does not help either.

Is it a known issue?!

try to add beginUpdates before inserting and endUpdates after inserting and tell me what will happen

[self.tableView beginUpdates];
[self.tableView insertSections:[NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, tableSectionsCount)] withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];

It is a simulator issue. No problems on the physical device!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM