Skip to content

Commit

Permalink
fix: not sub init memory
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Aug 14, 2023
1 parent b650480 commit 11b5a87
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
10 changes: 1 addition & 9 deletions core/sandbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,6 @@ static Result *run(Context *ctx) {
// 走到这了说明出错了
exit(EXIT::PRE_JUDGE_EXECLP);
} else {
long int init_mem = -1;

// 父进程
int status = 0; // 子进程状态
int syscall_id = 0; // 系统调用号
Expand All @@ -303,14 +301,8 @@ static Result *run(Context *ctx) {
exit(EXIT::JUDGE);
}

if (init_mem < 0) {
// 记录启动时使用的内存
init_mem = rused.ru_maxrss;
FM_LOG_TRACE("Init memory: %d KB", init_mem);
}

// MLE, using ru_maxrss (since Linux 2.6.32)
result->memory = std::max((long int) result->memory, rused.ru_maxrss - init_mem);
result->memory = std::max((long int) result->memory, rused.ru_maxrss);
if (result->verdict == Verdict::SE && result->memory > ctx->memory_limit) {
result->verdict = Verdict::MLE;
FM_LOG_TRACE("Memory Limit Exceeded (%d KB)", result->memory);
Expand Down
2 changes: 1 addition & 1 deletion core/test/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def run(executable, checker, source, testcase, expected):
commands = [executable, "-d", tmp_dir, "-l", source.split('.')[-1], "-s", checker]
if is_c_cpp:
# Restrict c/cpp memory usage
commands += ["-m", str(4 * 1024)]
commands += ["-m", str(8 * 1024)]

code = subprocess.call(commands, cwd=os.path.dirname(executable))

Expand Down

0 comments on commit 11b5a87

Please sign in to comment.