Want to know database behavior when Maximum cache size is exceeded
After extensive use of Email database (there were more than 1000 mails), Email App crashed. If i come back to App again all mails started deleting automatically.
The error logs obtained are as below:
E/AndroidRuntime( 417): java.lang.OutOfMemoryError
E/AndroidRuntime( 417): at java.lang.String.<init>(String.java:468)
E/AndroidRuntime( 417): at java.lang.AbstractStringBuilder.toString(AbstractStringBuilder.java:659)
E/AndroidRuntime( 417): at java.lang.StringBuilder.toString(StringBuilder.java:664)
E/AndroidRuntime( 417): at com.android.email.mail.transport.DiscourseLogger.addReceivingLineToBuffer(DiscourseLogger.java:57)
E/AndroidRuntime( 417): at com.android.email.mail.transport.DiscourseLogger.addReceivedByte(DiscourseLogger.java:70)
E/AndroidRuntime( 417): at com.android.email.mail.store.ImapResponseParser.readByte(ImapResponseParser.java:71)
E/AndroidRuntime( 417): at com.android.email.mail.store.ImapResponseParser.expect(ImapResponseParser.java:332)
E/AndroidRuntime( 417): at com.android.email.mail.store.ImapResponseParser.parseToken(ImapResponseParser.java:199)
E/AndroidRuntime( 417): at co开发者_开发问答m.android.email.mail.store.ImapResponseParser.readToken(ImapResponseParser.java:165)
E/AndroidRuntime( 417): at com.android.email.mail.store.ImapResponseParser.readTokens(ImapResponseParser.java:141)
E/AndroidRuntime( 417): at com.android.email.mail.store.ImapResponseParser.readResponse(ImapResponseParser.java:92)
E/AndroidRuntime( 417): at com.android.email.mail.store.ImapStore$ImapConnection.readResponse(ImapStore.java:1491)
E/AndroidRuntime( 417): at com.android.email.mail.store.ImapStore$ImapFolder.fetchInternal(ImapStore.java:887)
E/AndroidRuntime( 417): at com.android.email.mail.store.ImapStore$ImapFolder.fetch(ImapStore.java:810)
E/AndroidRuntime( 417): at com.android.email.MessagingController.synchronizeMailboxGeneric(MessagingController.java:898)
E/AndroidRuntime( 417): at com.android.email.MessagingController.synchronizeMailboxSynchronous(MessagingController.java:396)
E/AndroidRuntime( 417): at com.android.email.MessagingController.access$2(MessagingController.java:384)
E/AndroidRuntime( 417): at com.android.email.MessagingController$2.run(MessagingController.java:372)
E/AndroidRuntime( 417): at com.android.email.MessagingController.run(MessagingController.java:171)
E/AndroidRuntime( 417): at java.lang.Thread.run(Thread.java:1096)
W/Database( 497): Reached MAX size for compiled-sql statement cache for database /data/data/com.android.email/databases/EmailProvider.db; i.e., NO space for this sql statement in cache: SELECT _id FROM Attachment WHERE messageKey=996. Please change your sql statements to use '?' for bindargs, instead of using actual values
I want to know what is the behavior that I get the above error.
I mean what will android do if the Maximum cache size is exceeded? If you could tell where the implementation for that is done, it will be very helpful.
this is another issue. This message says it all: "Reached MAX size for compiled-sql statement cache for database"
basically the emaill application is using hardcoded values in the queries. Instead it should use prepared statements in order to cache only the prepared statements.
Hope it helps.
You have a way to set Max DB Size using setMaximumSize
.
You can have a thread checking the DB Size using getMaximumSiz
and if this is near to the DB size you have fixed before.
Then replicate(copy) your local DB to DB on SD card and release the memory using releaseMemory.
精彩评论