From b00db1af3e82d70eb60b95d67a0a15b1e84f4e5c Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 14 Oct 2020 12:44:27 +0200 Subject: [PATCH] only keep 20 outbound olm sessions in memory at once to prevent OOM --- src/matrix/e2ee/olm/Encryption.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/matrix/e2ee/olm/Encryption.js b/src/matrix/e2ee/olm/Encryption.js index ff5f1a8f..18bbc5fa 100644 --- a/src/matrix/e2ee/olm/Encryption.js +++ b/src/matrix/e2ee/olm/Encryption.js @@ -31,7 +31,9 @@ function findFirstSessionId(sessionIds) { const OTK_ALGORITHM = "signed_curve25519"; // only encrypt this amount of olm messages at once otherwise we run out of wasm memory // with all the sessions loaded at the same time -const MAX_BATCH_SIZE = 50; +// See https://github.com/vector-im/hydrogen-web/issues/150 as well, which indicates the limit is 44, +// but let's take a conservative limit as the megolm session cache also takes space +const MAX_BATCH_SIZE = 20; export class Encryption { constructor({account, olm, olmUtil, ownUserId, storage, now, pickleKey, senderKeyLock}) {