From dd171a2e9860b77240712a6717af64e1cc4e7e10 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Mon, 6 May 2019 22:32:05 +0000
Subject: [PATCH] Handle huge datasets better by calling js.gc(false) and
 flattening strings.

---
 exec/ircbots/dis/dis.js | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/exec/ircbots/dis/dis.js b/exec/ircbots/dis/dis.js
index 178d0817c3..48041ad93a 100644
--- a/exec/ircbots/dis/dis.js
+++ b/exec/ircbots/dis/dis.js
@@ -45,12 +45,15 @@ function get_posts_by(name, subs)
 					if(hdr.from.toLowerCase()==name.toLowerCase()) {
 						body=mb.get_msg_body(true, i, false, false, false).split(/\r?\n/);
 						for(j=0; j<body.length; j++) {
-							if(all[body[j]] !== undefined) {
-								body.splice(j,1);
-								j--;
-								continue;
-							}
-							all[body[j]]='';
+							try {
+								if(all[body[j]] !== undefined) {
+									body.splice(j,1);
+									j--;
+									continue;
+								}
+								all[body[j]]='';
+								js.gc(false);
+							} catch (e) { log("Out of memory "+e); }
 						}
 						body=word_wrap(body.join('\n', 65535)).split(/\n/);
 						for(j=body.length-1; j>=body.length/2; j--) {
@@ -72,8 +75,10 @@ function get_posts_by(name, subs)
 								continue;
 							if(body[j].search(/ "Real Fact" #[0-9]+:/)!=-1)
 								break;
-							if(body[j].search(/s*[\w]{0,2}[>:] /)==-1)
+							if(body[j].search(/s*[\w]{0,2}[>:] /)==-1) {
 								txt += body[j]+' ';
+								js.flatten_string(txt);
+							}
 						}
 					}
 				}
-- 
GitLab