summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Luby <plubius@neooffice.org>2023-06-22 08:13:42 +0100
committerMichael Meeks <michael.meeks@collabora.com>2023-06-22 09:56:50 +0100
commit0d1ffd2c163d6e8c15b66bcd4e80bba21b5994d6 (patch)
tree34d2976e0527a093e529dd7cd7e4e2a2e1e1163f
parentComment some more ... (diff)
downloadonline-logfix.tar.gz
online-logfix.zip
Limit memory usage of internal log storage. logfix
Otherwise it could grow without bound; now limited to 100 entries, each of <128 characters. Change-Id: I6a1b96a8cb6a67f991c3870f5b724989f65e0e74 Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--browser/src/core/Log.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/browser/src/core/Log.js b/browser/src/core/Log.js
index c2efd6b418..19651f0ec4 100644
--- a/browser/src/core/Log.js
+++ b/browser/src/core/Log.js
@@ -11,6 +11,14 @@ L.Log = {
if (!this._logs) {
this._logs = [];
}
+ // Limit memory usage of log by only keeping the latest entries
+ var maxEntries = 100;
+ while (this._logs.length > maxEntries)
+ this._logs.shift();
+ // Limit memory usage of log by limiting length of message
+ var maxMsgLen = 128;
+ if (msg.length > maxMsgLen)
+ msg = msg.substring(0, maxMsgLen);
msg = msg.replace(/(\r\n|\n|\r)/gm, ' ');
this._logs.push({msg : msg, direction : direction,
coords : tileCoords, time : time});