Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
master
-
None
-
None
Description
While experimenting some more with the ExpireMailboxService, I noticed that it uses an unexpectedly high amount of heap memory. I tracked the issue down to SimpleMessageSearchIndex.searchResults(), which always uses FetchType.FULL when retrieving messages from the MessageMapper for non-UID searches. Thus it loads the entire mail into memory, even if it only needs to check the internalDate.
I propose to optimize the fetch type used at this point, so it depends on the actual requirements of the stated SearchQuery. For most queries, it will only need to retrieve the mail headers, which typically have a much smaller memory footprint than mail bodies. For certain cases it may avoid even that if it only needs the message metadata.
Besides a significant reduction in memory use, I also anticipate a certain amount of speed improvement when reducing/skipping content retrieval from blob storage.