From 7a3bc76eb01932568cbcc33ed07df06ba29b8f1b Mon Sep 17 00:00:00 2001 From: lfarvour-hims <167330977+lfarvour-hims@users.noreply.github.com> Date: Thu, 16 May 2024 12:01:07 -0500 Subject: [PATCH] Close StringIO object to avoid OOM Killer When this script operates without closing the StringIO objects, it is liable to run out of memory during execution because it is holding onto reasonably large StringIO objects from the recorded future CSV files. Add an explicit close after chunking the file to clean the object out of memory. --- bin/scripts/rfsllookups.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/scripts/rfsllookups.py b/bin/scripts/rfsllookups.py index 8833d73..7ae6267 100644 --- a/bin/scripts/rfsllookups.py +++ b/bin/scripts/rfsllookups.py @@ -137,6 +137,7 @@ def sumologic_populate(self): lookupfileid = self.lookup_ids[ioc_type] risklist_as_file = StringIO(self.risklists[ioc_type]) chunks = self.split_csv(risklist_as_file, ioc_type) + risklist_as_file.close() for idx, chunk in enumerate(chunks): if ARGS.verbose > 4: print(f'Uploading {ioc_type} risklist chunk {idx+1} of {len(chunks)}')