diff options
-rw-r--r-- | browser/src/core/Log.js | 8 |
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}); |