问题
I am using Core Data. From there i am retrieving 10000+ data
Using NSOperation, i am displaying huge data on UITableView.
but as i can see in XCode Instruments my memory usage continuously increasing
thats the reason, crashing activity is there in device not in simulator
Any one would like to comment on this ?
回答1:
Don't retrieve 10000 objects at once.
Use the NSAutoreleasePool and flush the pool at some consistent interval (interval to be determined via testing).
Every N iterations:
- save your context
- reset your context
- drain your pool
This will keep your memory usage down during import.
回答2:
Simulator has practically unlimited memory as it uses Mac's memory thus can even swap to hard drive. iDevice has on the other side very limited memory.
From your description it's not clear what you are doing wrong. It's up to you to analyse it, with Instruments you are already on a good way. Use Instruments's "Heapshot analysis" to find where your application is leaking memory. Recently bbum wrote a nice article about how to use it : http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/ . There's also a nice video from WWDC by Apple's engineers about using Instruments worth watching : http://developer.apple.com/videos/wwdc/2010/
来源:https://stackoverflow.com/questions/4131356/crashing-issue-due-to-memory-management-using-core-data