From bace77059801dd9c52b05145a509b4d0b23486dd Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 6 Oct 2021 16:24:29 +0200 Subject: [PATCH] Reduce memory usage --- app/src/main/java/com/sun/mail/imap/IMAPMessage.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/sun/mail/imap/IMAPMessage.java b/app/src/main/java/com/sun/mail/imap/IMAPMessage.java index bc05c50fa9..bda029c1ff 100644 --- a/app/src/main/java/com/sun/mail/imap/IMAPMessage.java +++ b/app/src/main/java/com/sun/mail/imap/IMAPMessage.java @@ -100,8 +100,7 @@ public class IMAPMessage extends MimeMessage implements ReadableMime { * * Could this somehow be included in the InternetHeaders object ?? */ - private Hashtable loadedHeaders - = new Hashtable<>(1); + private Hashtable loadedHeaders; // This is our Envelope static final String EnvelopeCmd = "ENVELOPE INTERNALDATE RFC822.SIZE"; @@ -1168,7 +1167,7 @@ public class IMAPMessage extends MimeMessage implements ReadableMime { */ public synchronized void invalidateHeaders() { headersLoaded = false; - loadedHeaders.clear(); + loadedHeaders = null; headers = null; envelope = null; bs = null; @@ -1676,6 +1675,8 @@ public class IMAPMessage extends MimeMessage implements ReadableMime { private boolean isHeaderLoaded(String name) { if (headersLoaded) // All headers for this message have been loaded return true; + if (loadedHeaders == null) + return false; return loadedHeaders.containsKey(name.toUpperCase(Locale.ENGLISH)); } @@ -1684,6 +1685,8 @@ public class IMAPMessage extends MimeMessage implements ReadableMime { * Mark that the given headers have been loaded from the server. */ private void setHeaderLoaded(String name) { + if (loadedHeaders == null) + loadedHeaders = new Hashtable<>(1); loadedHeaders.put(name.toUpperCase(Locale.ENGLISH), name); } @@ -1756,7 +1759,7 @@ public class IMAPMessage extends MimeMessage implements ReadableMime { envelope.cc == null && envelope.inReplyTo == null && envelope.messageId == null && - headersLoaded && loadedHeaders.size() == 0) { + headersLoaded && (loadedHeaders == null || loadedHeaders.size() == 0)) { eu.faircode.email.Log.w("Expunged workaround host=" + ((IMAPStore) folder.getStore()).host); return true; }