mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-12 06:08:25 -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:
parent
524dfb348a
commit
4ea6c1603b
@ -48,6 +48,8 @@ public class LocalStore extends Store implements Serializable
|
||||
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 int MAX_SMART_HTMLIFY_MESSAGE_LENGTH = 1024 * 256 ;
|
||||
|
||||
private String mPath;
|
||||
private SQLiteDatabase mDb;
|
||||
private File mAttachmentsDir;
|
||||
@ -2433,6 +2435,18 @@ public class LocalStore extends Store implements Serializable
|
||||
|
||||
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);
|
||||
StringBuilder buff = new StringBuilder(text.length() + 512);
|
||||
int c = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user