Skip to content

Memory limiting does not work on macOS #379

Open
@s3rvac

Description

@s3rvac

The limiting of memory via --max-memory does not work properly on macOS. For example, if you run

$ retdec-fileinfo --max-memory=4096 FILE

the analysis (properly) fails on Linux and Windows, but finishes successfully on macOS. The reason is that on macOS, the following piece of code from src/utils/memory.cpp compiles, runs, returns 0 (success), but does actually not do anything:

struct rlimit rl = {
    .rlim_cur = limit,        // Soft limit.
    .rlim_max = RLIM_INFINITY // Hard limit (ceiling for rlim_cur).
};
auto rc = setrlimit(RLIMIT_AS, &rl);

From what I was able to find, setrlimit() with RLIMIT_AS is broken on macOS and simply does not work.

What is the proper way of programmatically limiting virtual memory on macOS? Feel free to submit a PR that fixes the implementation of limitSystemMemoryOnMacOS() in src/utils/memory.cpp.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions