Skip to content

Memory Limit Exceeded Error in Java and JavaScript #13

Description

@jeewoo1025

Dear Authors, (@Jackal1586 @sbmaruf )

Thank you for your excellent work on this project!

We encountered consistent "MEMORY_LIMIT_EXCEEDED" errors when executing Java (Java 17) and JavaScript code, while other languages like Python and Rust ran successfully. Could you please advise how to resolve this issue?

The problem occurred during execution of the xCodeEval/prog_syn_val.jsonl file (Program synthesis - compact version).

Error Logs: Java

[2025-07-05 04:50:29 +0000] [80] [INFO] api/execute_code: lang=Java 17 time: 0.545601952s, |uts|=3, exec_outcome=MEMORY_LIMIT_EXCEEDED, peak_mem=2484732kB, peak_time=0.01s
[2025-07-05 04:50:42 +0000] [80] [INFO] api/execute_code: lang=Java 17 time: 0.603471879s, |uts|=3, exec_outcome=MEMORY_LIMIT_EXCEEDED, peak_mem=2484732kB, peak_time=0.01s
... (repeated across all runs) 

Error Logs: Javascript

[2025-07-05 05:04:35 +0000] [82] [INFO] api/execute_code: lang=JavaScript time: 0.076938253s, |uts|=3, exec_outcome=MEMORY_LIMIT_EXCEEDED, peak_mem=77508kB, p_time=-1s
[2025-07-05 05:04:35 +0000] [79] [INFO] api/execute_code: lang=JavaScript time: 0.050247019s, |uts|=13, exec_outcome=MEMORY_LIMIT_EXCEEDED, peak_mem=77508kB, k_time=-1s
... (repeated across all runs) 

Reference Configurations

Docker file

📢 Note: We could not download from oracle.com due to network issue, so "jdk-17.0.7_linux-x64_bin.tar.gz" was placed directly in the folder.

FROM ubuntu:jammy

WORKDIR /root

ENV DEBIAN_FRONTEND noninteractive
ENV TZ Etc/UTC

RUN apt-get update && \
    apt-get install -y \
        gnupg ca-certificates apt-utils \
        build-essential curl unzip && \
    apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list

RUN apt-get update && \
    apt-get install -y tzdata

RUN apt-get install -y mono-devel \
        gcc-12 g++-12

RUN apt-get update && \
    apt-get install -y software-properties-common python3.11-dev

RUN apt-get update && \
    apt-get install -y -f libasound2 libc6-i386 libc6-x32 libxi6 libxtst6

ENV JAVA_HOME=/usr/java/jdk-17.0.7

COPY jdk-17.0.7_linux-x64_bin.tar.gz /tmp/jdk.tgz

RUN mkdir -p "$JAVA_HOME" && \
    tar --extract --file /tmp/jdk.tgz --directory "$JAVA_HOME" --strip-components 1 && \
    rm /tmp/jdk.tgz

RUN curl -OL https://github.com/JetBrains/kotlin/releases/download/v1.7.20/kotlin-compiler-1.7.20.zip

RUN unzip kotlin-compiler-1.7.20.zip -d /usr/local && \
    rm kotlin-compiler-1.7.20.zip

RUN apt-get install -y python2

RUN curl -OL https://go.dev/dl/go1.19.2.linux-amd64.tar.gz

RUN tar -C /usr/local -xzf go1.19.2.linux-amd64.tar.gz && \
    rm go1.19.2.linux-amd64.tar.gz

RUN curl -OL https://downloads.python.org/pypy/pypy3.9-v7.3.9-linux64.tar.bz2

RUN tar -C /usr/local -xf pypy3.9-v7.3.9-linux64.tar.bz2 && \
    rm pypy3.9-v7.3.9-linux64.tar.bz2

RUN curl -OL https://downloads.python.org/pypy/pypy2.7-v7.3.9-linux64.tar.bz2

RUN tar -C /usr/local -xf pypy2.7-v7.3.9-linux64.tar.bz2 && \
    rm pypy2.7-v7.3.9-linux64.tar.bz2

RUN apt-get install -y clang-14

ARG NODE_VERSION=v16.17.1
ARG NODE_DISTRO=linux-x64
ARG NODE_ZIP=node-$NODE_VERSION-$NODE_DISTRO.tar.xz

RUN curl -OL https://nodejs.org/dist/$NODE_VERSION/$NODE_ZIP

RUN tar -C /usr/local -xJvf $NODE_ZIP && \
    rm $NODE_ZIP

ENV RUSTUP_HOME /opt/rust
ENV CARGO_HOME /opt/rust

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path

RUN apt-get install -y ruby-full

RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing php8.1

RUN apt-get install -y libgmp-dev libmpfr-dev

ENV PATH $PATH:/usr/local/go/bin:/usr/local/kotlinc/bin:/usr/local/node-v16.17.1-linux-x64/bin:/opt/rust/bin

WORKDIR /root

RUN update-alternatives --install /usr/bin/java java "$JAVA_HOME"/bin/java 100 && \
    update-alternatives --install /usr/bin/javac javac "$JAVA_HOME"/bin/javac 100 && \
    update-alternatives --install /usr/bin/jar jar "$JAVA_HOME"/bin/jar 100 && \
    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 && \
    update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 && \
    update-alternatives --install /usr/bin/python python /usr/bin/python3.11 100 && \
    update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 100 && \
    update-alternatives --install /usr/bin/pypy2 pypy2 /usr/local/pypy2.7-v7.3.9-linux64/bin/pypy2 100 && \
    update-alternatives --install /usr/bin/pypy3 pypy3 /usr/local/pypy3.9-v7.3.9-linux64/bin/pypy3 100

RUN apt-get install -y python3-pip gperf

RUN pip install flask gunicorn flask-cors gmpy2 Cython jsonlines fire

RUN curl -o libseccomp.tar.gz -L https://github.com/seccomp/libseccomp/releases/download/v2.5.4/libseccomp-2.5.4.tar.gz

RUN tar -xzvf libseccomp.tar.gz && cd libseccomp-2.5.4 && chmod +x configure

WORKDIR /root/libseccomp-2.5.4

RUN ./configure --prefix=/usr --enable-python && make

RUN make install

WORKDIR /root/

RUN rm -rf libseccomp*

ENV RUN_UID 1586
ENV RUN_GID 1586
ENV NUM_WORKERS 16
ENV GUNICORN_PORT 5000
ENV WORKER_CFG_DB /root/worker_cfg_db.csv
ENV LOG_LEVEL info

# RUN groupadd -g ${RUN_GID} runner${RUN_GID} && useradd -M runner${RUN_UID} -g ${RUN_GID} -u ${RUN_UID}

EXPOSE ${GUNICORN_PORT}

RUN mkdir execution_engine

COPY ./execution_engine /root/execution_engine

WORKDIR /root/execution_engine

CMD ["bash", "start_engine.sh"]

execution_engine/limits_by_lang.yaml

📢 Note: We tried increasing Java’s memory limit to 4096MB, but the error persists.

...

Java 17:  
    nofile: 4096 
    nproc: 2048
    memory: 4096MB

Questions for Clarification

Could the observed memory usage (~2.48GB for Java, ~75MB for JS) exceed the configured environment limits?

Thank you for your guidance! 😊

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions