I’m developing a app in Searching with sqlite database using ARC.
I have to retrieve data from database into NSMutableArray to show retrieved data when textDidChange Event of UISearchBar.
It’s has alot of data retrieve from database when textDidChange of UISearchBar.
After retrieved alot of data from database,i have always clear from NSMutableArray with following codes.
[self.myArrayData removeAllObjects];
However i remove all of data from NSMutableArray , memory allocations are still occurring.
Not reduced.
Next time when i type something in UISearchBar, memory allocations are still increasing.
After i typed 10 times or above,I receive memory warning from XCodes and out of memory.
I want to know why data from NSMutableArray isn’t clear when i called removeAllObjects method.
I am developing my app with ARC.
Please help me.
You don’t have a lot of information here but it may not be NSMutableArray holding on to the data. SQLite also keeps a cache of recently retrieved records. You can reduce/remove the SQLCache by executing this after you’ve opened the database. Set the cache size to the number of pages you want SQLite to cache. The default is 2000. Each page is 1024 bytes in size.
EDIT: Technically you can’t reduce the cache below 10. If you try, the program will simply set the cache to 10.