2

I am using a sqlite query to get nutrient values for a specific food item from USDA database. The query works fine, when tried in simulator, but results in crash on device sometimes. I am including the USDA database in the app itself. Also the table on which the query is getting executed holds more than 5 lac records. I am getting 'Level 1 Memory Warning' at the launch of application. I cannot go for webservices, as the requirement is to give offline support.

Any suggestions how to handle this situation??

Edit :

In the log I get Signal 0 message

Program received signal: “0”. Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")

Vaibhav Tekam
  • 2,344
  • 3
  • 18
  • 27

3 Answers3

2

I guess the size of the database is causing the crash... If you are using this database as read only then you can use the compressed and encrypted form ... you can get more details from here http://www.hwaci.com/sw/sqlite/cerod.html this might help you get rid of the memory warnings.. here is another link which can help you reduce the size of the database.... How to reduce the size of an sqlite3 database for iphone?

Community
  • 1
  • 1
Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115
2

You are exhausting your app's memory. I am not a DB expert but you will have to use some special techniques to access your huge data base. Perhaps execute multiple queries serially in different sections of the DB. Or divide the DB into segments. Following are some references related to the crash you are seeing-

Program received signal: “0”. Data Formatters temporarily unavailable

Data Formatters temporarily unavailable

Data Formatters temporarily unavailable, will re-try after a 'continue'

There are more if you search for the error message.

halfer
  • 19,824
  • 17
  • 99
  • 186
Akshay
  • 5,747
  • 3
  • 23
  • 35
  • Thanks Akshay for the response. Indexing the tables did the trick!! – Vaibhav Tekam Oct 04 '11 at 04:56
  • Thanks Akshay, once again, but indexing was a call made by my instinct. It was nowhere suggested in the links you provided. Aquertu's suggestion seems to be very good, but haven't tested its feasibility. I am confused whose answer to accept. You guys take the call. – Vaibhav Tekam Oct 08 '11 at 09:39
2

Memory Related Crashes are quite common for ios apps I've noticed that more stable apps tend to manually manage memory alot over just letting the device manage it. I think if you split it up into sections instead of reading off one file and like akshay said index the tables it will be more stable. You could try reading files from compressed zips which would be more efficient over just plain old reading.

Aquertu
  • 174
  • 1
  • 8
  • Thank you your +1 is very much appreciated :D I don't know of any links much of – Aquertu Oct 05 '11 at 07:34
  • My knowledge is from personal experience, iphones and ipod touchs only have about 150mb (at least on the 4th gens) so instead of loading some massive 5-10mb into memory divide the file into several smaller files so that A) your loading much faster, B) your not eating memory, and C) no more crashs(well not by your app anyway) and indexing them makes it that much faster. – Aquertu Oct 05 '11 at 07:47
  • http://stackoverflow.com/questions/1925002/how-can-i-compress-data-using-zlib-without-directly-using-zlib-dylib theres a link on that post that shows you how to compress data with cocoa – Aquertu Oct 05 '11 at 07:53
  • This is a real great suggestion Aquertu. – Vaibhav Tekam Oct 08 '11 at 09:36
  • Thanks i'm kinda suprised myself you know kinda thought of it on the spot I'm not of much help sql wise though also thanks to whoever plus oned me again :) oh remember theres a trade off larger files plus compression will expand your memory usage so as long as you dont make the files really big you dont have to worry about the decompression eating ram too much. Plus 1'd your question :) – Aquertu Oct 09 '11 at 08:42
  • To test it you could write a small app that reads a text file of say 5mb then run the same file compressed and the decide between compressed and split up. By the what is this app for?(like what is the end user going to do with it?) if you don't mind me asking. Oh yeah dont gui the test app for the simple reason that if your iDevice is Jailbroke you can install the unix utils and use the unix time program to get the times – Aquertu Oct 09 '11 at 08:47
  • As for the xcode debugger.dylib make sure you arent compiling a debug application or rather trying to run a debug program on the device itself as far as i know the device itself cant run apps with debug symbols however the simulator should work fine. But considering the warning I'd say either you've imported and linked the wrong library or your just linking against a library that isnt meant for actual use with the device maybe like a simulator only lib. – Aquertu Oct 09 '11 at 08:54