Skip to main content
1 of 4
Kab
  • 165
  • 7

I tried Pillsys Method but didn't have any success. So I tried a different route by writing a batch file that will monitor the MathKernels and kills them if they have a page fault of over one million. Credit goes to DavidPostill for pointing me to Sysinternals (see here).

  1. Download Sysinternals Suite from https://technet.microsoft.com/de-de/sysinternals/bb842062.aspx

  2. Make the programs visible by adding the folder (in my case ";d:\scripts\SysintervalsSuite") to the PATH variable in Windows

  3. Add the folowing script in "d:\scripts\checkmathkernels.bat":

    @echo off
    SETLOCAL ENABLEEXTENSIONS
    setlocal EnableDelayedExpansion
    REM Dieses script soll MathKernels schließen die eine zu hohe (>1M) page fault haben. Es prüft alle 60 Sekunden.
    REM Der folgende Aufruf liest alle MathKernel Prozesse aus. PIDs sind an Stelle 2. (Page)Faults sind an Stelle 7.
    REM pslist -m -nobanner MathKernel | findstr /C:"MathKernel"
    :start
    set "output_cnt=0"
    for /f "tokens=2,7 " %%e in ('pslist -m -nobanner MathKernel ^| findstr /C:"MathKernel"') do (
        set /a output_cnt+=1    
        set "pids[!output_cnt!]=%%e"    
        set "faults[!output_cnt!]=%%f"    
    )
    REM Ausgabe:
    echo PID  faults
    for /L %%n in (1 1 !output_cnt!) DO (
        if !faults[%%n]! GTR 1000000 (
        call taskkill /f /PID !pids[%%n]!
    )
    echo !pids[%%n]! !faults[%%n]!
    )
    timeout /T 60
    goto start
    
  4. Call bat from Mathematica

Kab
  • 165
  • 7