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

+4
View File
@@ -28,6 +28,10 @@ total_time_limit:
name: total_time_limit name: total_time_limit
desc: Total time limit per problem desc: Total time limit per problem
default: 60 default: 60
memoryMax:
type: text
name: memoryMax
default: 512m
retry_delay_sec: retry_delay_sec:
type: number type: number
name: retry_delay_sec name: retry_delay_sec
+1
View File
@@ -14,6 +14,7 @@ let config = {
tmp_dir: path.resolve(os.tmpdir(), 'hydro', 'judge'), tmp_dir: path.resolve(os.tmpdir(), 'hydro', 'judge'),
tmpfs_size: '256m', tmpfs_size: '256m',
stdio_size: '32m', stdio_size: '32m',
memoryMax: '512m',
retry_delay_sec: 15, retry_delay_sec: 15,
sandbox_host: 'http://localhost:5050', sandbox_host: 'http://localhost:5050',
testcases_max: 100, testcases_max: 100,
+3 -1
View File
@@ -2,7 +2,7 @@ import Axios from 'axios';
import fs from 'fs-extra'; import fs from 'fs-extra';
import { argv } from 'yargs'; import { argv } from 'yargs';
import * as STATUS from './status'; import * as STATUS from './status';
import { SystemError } from './error'; import { FormatError, SystemError } from './error';
import { cmd, parseMemoryMB } from './utils'; import { cmd, parseMemoryMB } from './utils';
import { getConfig } from './config'; import { getConfig } from './config';
import { Logger } from './log'; import { Logger } from './log';
@@ -31,6 +31,8 @@ function proc({
stdin = '', copyIn = {}, copyOut = [], copyOutCached = [], stdin = '', copyIn = {}, copyOut = [], copyOutCached = [],
} = {}) { } = {}) {
const size = parseMemoryMB(getConfig('stdio_size')); const size = parseMemoryMB(getConfig('stdio_size'));
const memoryMax = parseMemoryMB(getConfig('memoryMax'));
if (memory > memoryMax) throw new FormatError('Memory limit larger than memory_max');
return { return {
args: cmd(execute.replace(/\$\{dir\}/g, '/w')), args: cmd(execute.replace(/\$\{dir\}/g, '/w')),
env, env,