1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-16 14:35:04 -05:00

We've been seeing a lot of FCs on htmlifcation of large messages due to

running out of memory during our heavy HTMLification. Try to be a bit
lighter on the poor RAM if a plain text message is big.
This commit is contained in:
Jesse Vincent 2010-10-23 17:33:08 +00:00
parent 524dfb348a
commit 4ea6c1603b

View File

@ -48,6 +48,8 @@ public class LocalStore extends Store implements Serializable
private static final int DB_VERSION = 39; private static final int DB_VERSION = 39;
private static final Flag[] PERMANENT_FLAGS = { Flag.DELETED, Flag.X_DESTROYED, Flag.SEEN, Flag.FLAGGED }; private static final Flag[] PERMANENT_FLAGS = { Flag.DELETED, Flag.X_DESTROYED, Flag.SEEN, Flag.FLAGGED };
private static final int MAX_SMART_HTMLIFY_MESSAGE_LENGTH = 1024 * 256 ;
private String mPath; private String mPath;
private SQLiteDatabase mDb; private SQLiteDatabase mDb;
private File mAttachmentsDir; private File mAttachmentsDir;
@ -2433,6 +2435,18 @@ public class LocalStore extends Store implements Serializable
public String htmlifyString(String text) public String htmlifyString(String text)
{ {
// Our HTMLification code is somewhat memory intensive
// and was causing lots of OOM errors on the market
// if the message is big and plain text, just do
// a trivial htmlification
if (text.length() > MAX_SMART_HTMLIFY_MESSAGE_LENGTH)
{
return "<html><head/><body>" +
htmlifyMessageHeader() +
text +
htmlifyMessageFooter() +
"</body></html>";
}
StringReader reader = new StringReader(text); StringReader reader = new StringReader(text);
StringBuilder buff = new StringBuilder(text.length() + 512); StringBuilder buff = new StringBuilder(text.length() + 512);
int c = 0; int c = 0;