Unfortunately the string building at step 3 happens in a way that interacts terribly with compartment-per-global; for some reason the string assignment is happening across a compartment boundary and among other things this forces the JS string to be flattened, so there is insane amounts of memory allocation going on inside a tight loop that doesn't have any GC pauses - so we both burn huge amounts of CPU copying strings, and we blow out the heap by keeping all the copies.
The quick fix is to make selectionsummaries.js pass the "saneBodySize:true" flag to MsgHdrToMimeMessage() - this stops the gloda builder from reassembling the entire string.
This still leaves behind a cruel trap for anyone else who uses the Gloda mime engine, we need to fix the underlying problem as well.
OK, so it's a combination of things:
1) the message summary generator uses Gloda's mime structure builder to parse content out of messages, in order to get the first couple of lines to summarize: https:/ /mxr.mozilla. org/comm- central/ source/ mail/base/ content/ selectionsummar ies.js# 585
2) libmime splits messages into text lines and calls the mime "emitter" with the message content line-by-line
3) Gloda's builder reassembles that content into a single string for plaintext and html parts: https:/ /mxr.mozilla. org/comm- central/ source/ mailnews/ db/gloda/ components/ jsmimeemitter. js#455
Unfortunately the string building at step 3 happens in a way that interacts terribly with compartment- per-global; for some reason the string assignment is happening across a compartment boundary and among other things this forces the JS string to be flattened, so there is insane amounts of memory allocation going on inside a tight loop that doesn't have any GC pauses - so we both burn huge amounts of CPU copying strings, and we blow out the heap by keeping all the copies.
The quick fix is to make selectionsummar ies.js pass the "saneBodySize:true" flag to MsgHdrToMimeMes sage() - this stops the gloda builder from reassembling the entire string.
This still leaves behind a cruel trap for anyone else who uses the Gloda mime engine, we need to fix the underlying problem as well.