8000 feat(ENGKNOW-2158): Count low memory exceptions by gmagnu · Pull Request #47 · gorpipe/gor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(ENGKNOW-2158): Count low memory exceptions #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions gortools/src/main/scala/gorsat/Monitors/MemoryMonitor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package gorsat.gorsatGorIterator

import org.gorpipe.exceptions.custom.GorLowMemoryException
import org.slf4j.{Logger, LoggerFactory}


Expand Down Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion tests/data
Submodule data updated 1 files
+12 −0 nor/nor_with_tabs.nor
Loading
0