Note that the memory problem is not only in the produced mail: the events are also all loaded at once before rendering. DefaultPeriodicMimeMessageIterator sets expectedCount = Integer.MAX_VALUE / 4, which DefaultParametrizedNotificationManager#getRawEvents turns into a single search of ~1 billion rows (the MAX_BATCH_SIZE of 1280 is never reached since the batch size already starts above it). So all the events a user listens to since the last trigger end up in memory at the same time, e.g. when a user watching a space receives daily mails and hundreds of thousands of pages are created in that space during the day (see XWIKI-10594). Paginating the mails should also paginate the retrieval of the events.
This message was sent by Atlassian Jira (v9.3.0#930000-sha1:287aeb6)
If image attachments aren't displayed, see this article.