def METHOD_NAME():
    try:
        proc = subprocess.Popen(
            ["bash", "-c", "ulimit -a"],
            preexec_fn=make_process_independent,  # make the process its own process group
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
        ulimit_stdout_bytes, _ = proc.communicate()
        ulimit_lines = ulimit_stdout_bytes.decode().splitlines()
    except OSError:
        return
    memory_limit_keys = [
        "max memory size",  # -m bash
        "resident set size",  # -m zsh
        "virtual memory",  # -v bash
        "address space",  # -v zsh
        "data seg size",  # -d
    ]
    memory_limit_re = "(?:" + "|".join(memory_limit_keys) + ")"
    memory_limits = set()
    for p in ulimit_lines:
        m = re.fullmatch(r".*{:s}[^\d]*(?P<limit>\d+)".format(memory_limit_re), p)
        if m is None:
            continue
        limit_in_kilobytes = int(m.group("limit"))
        if limit_in_kilobytes <= 0:
            continue
        memory_limits.add(limit_in_kilobytes)
    if len(memory_limits) > 0:
        return min(memory_limits) * ureg.kilobytes