From 500ac66031e24aff60661c729d402e4867032be6 Mon Sep 17 00:00:00 2001 From: Gisli Magnusson Date: Mon, 5 May 2025 15:49:48 +0000 Subject: [PATCH 1/2] Add test data. --- tests/data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data b/tests/data index 16069188..306332b1 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit 16069188d0d602c5b08233a8f6696f5c3ded6e78 +Subproject commit 306332b13d9188fe136477538e8c8a91bb952eaa From 3cfb3684f675d36a60097cffa29d4257db7b8e38 Mon Sep 17 00:00:00 2001 From: Gisli Magnusson Date: Mon, 5 May 2025 18:10:52 +0000 Subject: [PATCH 2/2] feat(ENGKNOW-2158): Count number of lowmemory exceptions. --- .../src/main/scala/gorsat/Monitors/MemoryMonitor.scala | 8 ++------ .../gorsat/gorsatGorIterator/MemoryMonitorUtil.scala | 8 ++++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gortools/src/main/scala/gorsat/Monitors/MemoryMonitor.scala b/gortools/src/main/scala/gorsat/Monitors/MemoryMonitor.scala index 8ba375a6..d8aaba9e 100644 --- a/gortools/src/main/scala/gorsat/Monitors/MemoryMonitor.scala +++ b/gortools/src/main/scala/gorsat/Monitors/MemoryMonitor.scala @@ -24,21 +24,17 @@ package gorsat.Monitors import gorsat.Commands.Analysis import gorsat.gorsatGorIterator.MemoryMonitorUtil -import org.gorpipe.exceptions.custom.GorLowMemoryException import org.gorpipe.gor.model.Row case class MemoryMonitor(logname: String, minFreeMemMB: Int = MemoryMonitorUtil.memoryMonitorMinFreeMemMB, minFreeMemRatio: Float = MemoryMonitorUtil.memoryMonitorMinFreeMemRatio) extends Analysis { - val mmu: MemoryMonitorUtil = new MemoryMonitorUtil((actualFreeMem: Long, args: List[_]) => { - val msg = "MemoryMonitor: Out of memory executing " + logname + "(line " + mmu.lineNum + "). Free mem down to " + actualFreeMem / mmu.bytesInMB + " MB.\n" + args.head - throw new GorLowMemoryException(msg) - }, minFreeMemMB, minFreeMemRatio) + val mmu: MemoryMonitorUtil = new MemoryMonitorUtil(MemoryMonitorUtil.basicOutOfMemoryHandler, minFreeMemMB, minFreeMemRatio) override def isTypeInformationMaintained: Boolean = true override def process(r: Row): Unit = { - mmu.check(r) + mmu.check(logname, mmu.lineNum, r) super.process(r) } } \ No newline at end of file diff --git a/model/src/main/scala/gorsat/gorsatGorIterator/MemoryMonitorUtil.scala b/model/src/main/scala/gorsat/gorsatGorIterator/MemoryMonitorUtil.scala index 71b6d03a..2128b2b7 100644 --- a/model/src/main/scala/gorsat/gorsatGorIterator/MemoryMonitorUtil.scala +++ b/model/src/main/scala/gorsat/gorsatGorIterator/MemoryMonitorUtil.scala @@ -22,6 +22,7 @@ package gorsat.gorsatGorIterator +import org.gorpipe.exceptions.custom.GorLowMemoryException import org.slf4j.{Logger, LoggerFactory} @@ -108,11 +109,14 @@ object MemoryMonitorUtil { val memoryMonitorActive: Boolean = (memoryMonitorMinFreeMemMB > 0 || memoryMonitorMinFreeMemRatio > 0) && memoryMonitorRowsBetweenChecks > 0 + var lowMemoryExceptions: List[String] = List() + def basicOutOfMemoryHandler(actualFreeMem: Long, args: List[_]) : Unit = { val logName = args.head val lineNum = args(1) val line = args(2) - val msg = "MemoryMonitor: Out of memory executing " + logName + " (line " + lineNum + "). Free mem down to " + actualFreeMem / (1024L * 1024L) + " MB.\n" + line - throw new Exception(msg) + val msg = "MemoryMonitor: Out of memory executing: " + logName + " (line " + lineNum + "). Free mem down to " + actualFreeMem / (1024L * 1024L) + " MB.\n" + line + lowMemoryExceptions = lowMemoryExceptions :+ msg + throw new GorLowMemoryException(msg) } } \ No newline at end of file