judge: add memoryMax limit

This commit is contained in:
undefined committed 2021-04-19 12:34:22 +08:00
1 parent 8435f4002b
commit a3b1f7e640
3 files changed
+8 -1

No files matched your search

+3 -1
View File
@@ -2,7 +2,7 @@ import Axios from 'axios';
import fs from 'fs-extra';
import { argv } from 'yargs';
import * as STATUS from './status';
import { SystemError } from './error';
import { FormatError, SystemError } from './error';
import { cmd, parseMemoryMB } from './utils';
import { getConfig } from './config';
import { Logger } from './log';
@@ -31,6 +31,8 @@ function proc({
stdin = '', copyIn = {}, copyOut = [], copyOutCached = [],
} = {}) {
const size = parseMemoryMB(getConfig('stdio_size'));
const memoryMax = parseMemoryMB(getConfig('memoryMax'));
if (memory > memoryMax) throw new FormatError('Memory limit larger than memory_max');
return {
args: cmd(execute.replace(/\$\{dir\}/g, '/w')),
env,